Invalid use of Null --> Help Please

F

FatMan

Hi all:
I am getting an invalid use of null in the if statement below (in Access
2000) and do not usnderstand why. Can anyone help me?

Background:
- rs has been declared as a recordset

- rs!GrowerEmail is the email address for our grower/customer

- the code below is part of the code used to email a report to our
growers/customers and works find for those records where the email address is
not blank/null.

- when I put in a control stop and run the program in debug mode and step
through each line of code and hover my mouse of "rs!GrowerEmail" in the "If
rs!GrowerEmail = Null then" part of the IF statement my mouse pointer display
"rs!GrowerEmail = Null". As well the debug.print statement just before the
IF statement will print out the GrowerFarmName and for the strGrowerEmail
part of the statement that should print "*EmailAddress* only prints "**"

Why will not the If statement recognize that rs!GrowerEmail is null? Any
help is greatly appreciated.

Thanks,
FatMan

Code follows.........

Debug.Print "strGrowerFarmName = " & strGrowerFarmName & " " &
"strGrowerEmail = *" & rs!GrowerEmail & "*" & " " & Len(rs!GrowerEmail)


If rs!GrowerEmail = Null Then
rs!GrowerEmail = "No email address on file"
Else
strGrowerEmail = rs!GrowerEmail
End If
 
J

Jon Lewis

You can't use Null in a comparative statement as no value can ever be equal
to Null (even Null itself!). The correct syntax is:

If IsNull(rs!GrowerEmail) Then
or
If Len(rs!GrowerEmail & "") = 0 Then

HTH
 
D

Dirk Goldgar

FatMan said:
Hi all:
I am getting an invalid use of null in the if statement below (in Access
2000) and do not usnderstand why. Can anyone help me?

Background:
- rs has been declared as a recordset

- rs!GrowerEmail is the email address for our grower/customer

- the code below is part of the code used to email a report to our
growers/customers and works find for those records where the email address
is
not blank/null.

- when I put in a control stop and run the program in debug mode and step
through each line of code and hover my mouse of "rs!GrowerEmail" in the
"If
rs!GrowerEmail = Null then" part of the IF statement my mouse pointer
display
"rs!GrowerEmail = Null". As well the debug.print statement just before
the
IF statement will print out the GrowerFarmName and for the strGrowerEmail
part of the statement that should print "*EmailAddress* only prints "**"

Why will not the If statement recognize that rs!GrowerEmail is null? Any
help is greatly appreciated.


This question was already posted twice yesterday and correctly answered both
times. Are you having trouble finding the replies to your posts? You can't
rely on getting an e-mail notification -- that feature seems not to be
working. If you need to, search the forum for your posting "handle".
 

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