Forcing users to input data

Danny

Registered User.
Local time
Today, 02:30
Joined
Jul 31, 2002
Messages
157
Greetings,

I have a worksheet when users enter a valid ID Number that will list a work list which corresponds to that ID number. However, if the user hit Enter without inputting data (ID number), then all worklist are returned, or say if users enter a non existing ID number, then the result is 0.

But, I would like the following to happen

1. If users forget to enter ID Number & hit enter, then they will get a
message saying : “Please Enter a valid ID Number”

2. If users enter a non–existing Id Number then they will get a
message saying “ ID Number Not Valid” “please enter a valid ID
Number”


Thank you in advance,
D
 
You could use the IsNull() function in the Text Box's On Lost Focus event to ensure the user enters a value. You can then use the DCount() to see if the user has entered a valid ID in Text Box's Before Update event
 
Your Lost Focus Code might look something like;
Code:
If IsNull(Me.YourFieldName) Then
     MsgBox "Please enter an ID Number"
     Cancel = True
End If

Your Before Update event might look something like;
Code:
If Dcount("IDFieldName", TableNameToCheck", "IDFieldName =" & Me.IDFieldName) = 0 Then
     MsgBox Me.IDFieldName & " is not valid please enter a valid ID"
     Cancel = True
     Me.IDFieldName.Undo
End If
 
Thanks everybody for your inputs. I’m going to apply your suggestion….

Regards,

D
 

Users who are viewing this thread

Back
Top Bottom