Need Coding Help Using Undo

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello to all,

Can anyone help me with coding for this problem.

I have four bound fields on a form. I want to prevent a record being saved
if the user don't fill in all the fields.

For example, the user fills in a student address and zip but leaves the name
field blank and moves to a different record. When this happens I want to Undo
the unfinished record but still allow them freedom to move to a different
record.

My limited programming skills suck at this kind of stuff. I'm guessing this
wil require an If, Then test in the OnExit property of each field or
something similar.

Thanks in advance...
 
You could do it on a field by field basis. Use the Before Update event:

If IsNull(Me.txtZip) Then
MsgBox "Zip Code is Required"
Cancel = True
End If

Since you are checking to see if anything has been entered in the control,
then you don't really need the Undo. The above code will tell the user the
zip code is required and leave the focus in the control.
 
Back
Top