If then help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Greetings all. I am using Access 2003 and I can not figure out how to get
the following to work in the click event of a command button.

If Me.cboEWO.Value = null Then
MsgBox "Enter an EWO"
Else
rest of code.

cboEWO is a combo used for searching. When a value is chosen by cascading
or entering in a value a command button is hit to pass the value to a stored
procedure. Upon hitting the command button I would like the user to see the
message if no value has been entered in cboEWO. I tried every variation of
the above, but my skills in Access are lacking. Thank you for any help.
 
You can't check for null with "= null" - you need to use the IsNull
function:

If IsNull(Me.cboEWO) Then
'dosomething
Else
'do something else
End If

If you want to go the other way, you can use:

If Not IsNull(me.cboEWO) then
'dosomething else
Else
'do something
End If

Similarly, in SQL, you would use "SELECT Field FROM Table WHERE Field Is
Null" rather than "field = Null"
 

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

Back
Top