form On Open

M

Mark

Hi all,

I have the following code on the "On Open" property of a
form. Basically, when the user opens the form... they are
asked to enter their Employee ID and then their NT Logon.
If there is a record containing that info, then the form
should open (as in the "else" statement below). However,
if there is not a record I would like a message box come
up and then not allow the form to be opened (as in
the "if" statement below). But the "If" statement is not
working... if there is not a record... the text box
(EmployeeID) is showing "#Error". How can I get this to
work???? Thanks!!!


Private Sub Form_Open(Cancel As Integer)

If IsNull(Me.EmployeeID) Then
MsgBox "The Employee ID and NT Logon is not
valid.", vbCritical, "Notice:"
Cancel = True
Else
MsgBox "Supervisor approval is required for class
enrollment.", vbExclamation, "Notice:"
End If

End Sub
 
S

Sean

If there is no record then Me.EmployeeID very possibly is not null. It
might be EMPTY or something. have you tested that???

Setting Cancel to true will cancel trhe opening of the form, so test your
if CONDITION.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top