Question : Access / VBA / return to previous record after form after update event triggers

hello,

I have a form and i'm using the form's "after update" event to trigger a code.
the code checks if all the data is entered correctly in the form, and if not it shows a msgbox to the user.  this part works fine.

in the cases where the "after update" event triggers as a result of trying to close the form or trying to move to the next/previous record (i have buttons for this on the form), i want to make sure that the code disables the closing/moving records, so the current form and record will keep on showing in order to force the user to correct the data.

how do i do that?

thanks :)

Answer : Access / VBA / return to previous record after form after update event triggers

Use the before update event instead of the after update event.  If there are incorrect entries set
Cancel = True
to stop the update and change to another record.
 
To stop the closing of the form set
Cancel = True
in the Form Unload event.

See www.thenelson.name/#ReportFormTricks, "Check for required items" for an example of how to do it.
Random Solutions  
 
programming4us programming4us