By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,045 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,045 IT Pros & Developers. It's quick & easy.

Nulls

P: n/a
Thanks for reading my question.. This Newsgroups is great!!

I'm having a senior moment and remember...

if I have a field in a record that is null and I want to do an IF
Statement based on if null or not what is the syntax

If [description ] is null then
msgbox("Description is empty)
End if

I get error "object is required"

If [description ] = null then
msgbox("Description is empty)
ELSE
msgbox("Description is not empty)
End if

It will take the Else leg of the if statement.

What is the correct code if description is null?

Thanks

N. Graves
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Use the IsNull() function to test if a value is null in VBA;
If IsNull(Me.[description]) Then

In VBA, the "Is" operator is reserved for examining objects, hence the
"object is required" error.

You cannot use "=" with Null, because two Nulls are not equal. In fact,
nothing is ever equal to Null. For an explanation, see:
Common errors with Null
at:
http://members.iinet.net.au/~allenbrowne/casu-12.html

The article explains that any comparision involving Null can have 3
outcomes: True, False, or Null (unknown).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"N. Graves" <ng*****@REMOVEyahoo.com> wrote in message
news:g1********************************@4ax.com...
Thanks for reading my question.. This Newsgroups is great!!

I'm having a senior moment and remember...

if I have a field in a record that is null and I want to do an IF
Statement based on if null or not what is the syntax

If [description ] is null then
msgbox("Description is empty)
End if

I get error "object is required"

If [description ] = null then
msgbox("Description is empty)
ELSE
msgbox("Description is not empty)
End if

It will take the Else leg of the if statement.

What is the correct code if description is null?

Thanks

N. Graves

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.