Invalid use of Null ----> Help Please

F

FatMan

Hi all:
I am getting an invalid use of null in the if statement below 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
 
D

Dirk Goldgar

FatMan said:
Hi all:
I am getting an invalid use of null in the if statement below 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


By the definition of Null, *nothing* ever equals Null (no matter what it
shows in the debugger's tooltip). In VBA code, test for Null using the
IsNull function:

If IsNull(rs!GrowerEmail) Then
 

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