Make user select from a drop down list if a number in another field is entered?

KevinSlater

Registered User.
Local time
Today, 10:49
Joined
Aug 5, 2005
Messages
249
Hi all, i have a 2 fields in a subform named "HRS_ABSENT" & "ABSENCE_REASON" i'm trying to create some code that will display a message if the user inputs any number into the "HRS_ABSENT" field & leaves the "ABSENCE_REASON" field empty. I want to force the user to select a ABSENCE RESON (these are 3 letter codes) from the drop down list, if they enter a number in the HRS ABSENT field. Ive tried the below code but it doesnt do anything :-(

Anybody please help me out?
-------------------------------------------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
If HRS_ABSENT = >0 & ABSENCE_REASON = FALSE Then
MsgBox "Please select an Absence reason"
Cancel = True
End If
 
You need to check if the Absence_Reason is null as follows

ISNull(ABSENCE_REASON) OR ABSENCE_REASON=""
 
Thanks Antomack, the following code works fine. Cheers for your help!

If HRS_ABSENT > 0 And IsNull(ABSENCE_REASON) Or ABSENCE_REASON = "" Then
MsgBox "Please select an absence reason for any hours absent"
Cancel = True
End If
 

Users who are viewing this thread

Back
Top Bottom