PLEASE HELP !!!!!!!!!!!!!!!!!

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

How do I put validation code in Before Update Event?
Please be very specific.,

I am tring to confirm that the field is not blank and if
so I would like to display an error message that
states "Please complete **** field"

THANKS _ MC
 
In the form editor... select the field. Ensure the properties dialog box is
open (if not, right click on the field and choose 'Properties'). On the
'Event' tab of the properties, find the 'Before Update' choice, and click
the down arrow of this box and choose [Event Procedure]. Then click the
button beside the box (with the three dots on it). The following will come
up;

Private Sub Field_Name_BeforeUpdate(Cancel As Integer)

End Sub

Now, the code can be a little different, depending on the data type of the
field (and the field name), so you may want to try something like;

Private Sub Field_Name_BeforeUpdate(Cancel As Integer)
If IsNull([Field Name]) Then
MsgBox "Please complete this field"
Cancel = True
End If
End Sub

Alternatively, you could edit the table definition (if this field is from a
table, instead of a text field) and ensure that the 'Allow Zero Length'
property is NO and the 'Required' property is YES....
 
Sorry for the confusion on my part the the complete code is
put on the "On exit" event not the "After Update"

If IsNull(Me![dateyy]) Then
Beep
MsgBox "*** Start Date must be entered ***"
DoCmd.CancelEvent
Else
End If

Jim
 
Back
Top