I've done some validation so that when the user goes against the validation rule, a message comes up. The problem is the cursor still goes on to the next field in the form. I want the focus not to move if the user has done something wrong. I used on lostfocus() so that it would be after the user had tabbed that the error message would come up. How do I get back to the field the user just left? (Hope this is clear enough?)
you can place some code in the controls lost focus event, and then force the focus back to the control if its invalid.
however its not neccesarily a good solution. The major problem is that you could have 2 columns adjacent to each other both with a validation rule that is triggered on lost focus. if you attempt to move between controls both will fire their lost focus event, if both are invaild you will loose control of the app as it toggles between 2 controls.
a smarter solution is to consider changing the background colour of controls which are invalid.
alternatively you place your validation code in the forms before update event and then display a message detiaing the problems.
you can place an error message in each invlaid control tooltip.
I'm sure there are many other options, just my 2 1/d's worth
the data being entered into the form is not being saved to the underlying table unless I close the form and reopen it. Is there a way for me to make it save when the user gets to the end of the record without closing the form?
When the user gets to the end of inputting data, I set it so that if they say yes they want to continue, it goes back to the beginning of the form fields and they could enter more data. At the moment, when the focus goes back to the first field and I check the table, the data for the previous record is not in there until after I close the form and reopen it. This is a bit worrying as I don't expect the user to keep opening and closing.
From your response, do you think I should do a 'new record button instead?'