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

Null

P: n/a


I am trying to write an "If" statement that looks like this.
If LName = Null Then
MsgBox "Last name can not be left blank"
End If
I can not get it to recognize Null. What is wrong with the statement,
or should be used instead of null.

Thank you,
Brenda

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
if isnull(LName) then..........

Damon
"Brenda" <br****@mycollegeinfo.com> wrote in message
news:41**********************@news.newsgroups.ws.. .


I am trying to write an "If" statement that looks like this.
If LName = Null Then
MsgBox "Last name can not be left blank"
End If
I can not get it to recognize Null. What is wrong with the statement,
or should be used instead of null.

Thank you,
Brenda

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #2

P: n/a
For more details, see my reply to the recent thread on optional parameters and
IsMissing.

On Wed, 18 Aug 2004 16:48:49 -0700, "Damon Heron" <da******@hotmail.com>
wrote:
if isnull(LName) then..........

Damon
"Brenda" <br****@mycollegeinfo.com> wrote in message
news:41**********************@news.newsgroups.ws. ..


I am trying to write an "If" statement that looks like this.
If LName = Null Then
MsgBox "Last name can not be left blank"
End If
I can not get it to recognize Null. What is wrong with the statement,
or should be used instead of null.

Thank you,
Brenda

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 13 '05 #3

P: n/a
use IsNull(variable)
Nov 13 '05 #4

P: n/a

Others have pointed out IsNull, from the way you describe the error your
trying to detect I think you may be better off with

If Len(Trim(LName & "")) < 1 Then
MsgBox "Last name can not be left blank"
End If

This will detect when
a) No entry is made (LName Is Null)
b) An empty string is entered (data has been entered and then deleted
gives rise to this)
c) Someone just taps the space bar
--
Terry Kreft
MVP Microsoft Access
"Brenda" <br****@mycollegeinfo.com> wrote in message
news:41**********************@news.newsgroups.ws.. .


I am trying to write an "If" statement that looks like this.
If LName = Null Then
MsgBox "Last name can not be left blank"
End If
I can not get it to recognize Null. What is wrong with the statement,
or should be used instead of null.

Thank you,
Brenda

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.