Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Validation

Status
Not open for further replies.

jbaier

IS-IT--Management
Jun 7, 2002
2
US
I setup some Vb code to check dates in my table for conflicts. the code works fine and is called with the before update portion of the new reservations forum. The problem is that althoguh it runs the code and pops up a message about conflicts It still updates/adds the record to the table and moves onto the next record. Is there a way to code it so that if the conflicts are found it won't update?
 
DoCmd.CancelEvent
may work for you...

what i usualy do is this...

in the if statement that tests if the data is correct, if it's not, display a message box, then goto an exit label...

hope this helps...

--James JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
put your validation code in the Before Update event. This creates a function with a Cancel parameter. If you find an error, report it and then set Cancel = True somewhere in the code. That will stop the update and return the focus to the error control. If you include me.controlname.undo it will return to the original value before the change.

Some of the event code sections are created with Cancel. In all of those cases, if you set cancel = true, control is returned to the error (eg even if you clicked on another control the cancel event will return you to the validated control).

Hope this helps!
 
Thanks Guys That Worked Great!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top