Prev: RunTime Error 3070
Next: Using textbox using a variable
From: FatMan on 17 May 2010 11:34 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
From: Dirk Goldgar on 17 May 2010 11:40 "FatMan" <FatMan(a)discussions.microsoft.com> wrote in message news:3354FFE3-70CD-435C-9A9C-C60CD621597E(a)microsoft.com... > 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 -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup)
From: mie via AccessMonster.com on 17 May 2010 11:46 Refer to your previous post, someone already answered your question. FatMan wrote: >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 -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201005/1
|
Pages: 1 Prev: RunTime Error 3070 Next: Using textbox using a variable |