If then help

G

Greg Snidow

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.
 
S

SusanV

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"
 
Top