Data Entry Validation

  • Thread starter Thread starter Melinda
  • Start date Start date
M

Melinda

I have a vehicle database with a field called ModelYear
with a format of yyyy. I also have an Registration
Expiration Date field with the short date format.
Question: On my data entry form, how do I enter a
validation rule that will keep the user from entereing a
registration expiration date that is prior to the model
year? Ex: Model year is 2004, vehicle expiration cannot
be prior to 2004.

Thanks.

Melinda
 
Hi Melinda

The best event to use for data validation of dependent fields is
Form_BeforeUpdate. You woould use code something like this:
If Year( Me.[RegExpDate] ) < Me.[ModelYear] Then
MsgBox "Put your message here"
Cancel = True
End If

Setting Cancel = True in BeforeUpdate prevents the record from being saved
until the conditions are satisfied.
 
Back
Top