Handling null from recordset

StefanOl

Registered User.
Local time
Today, 06:33
Joined
Nov 11, 2009
Messages
15
Hi

I have these lines of code

Set rstRs = dbsNorthwind.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)

While rstRs.EOF = False

If rstRs![assigned apm] Is Nothing Then
APMName = ""
Else
APMName = rstRs![assigned apm]
End If


But the IF statement does not work, it does not catch the
use case where the ![assigned apm] is null
The VBA halts on line

"APMName = rstRs![assigned apm]"

and report

"Invalid use of Null"

How should the IF statement be formulated in order to catch the NULL ?
or is it another way of handling the case where the result is NULL ?

Regards
 
PHP:
If isnull(rstRs![assigned apm]) then 

APMName = ""

else

blah blah
 
Hi

Yes, it works very well

Thanks a lot Adam

Regards
 
I would recommend the Nz() function here, which simplifies ...
Code:
If IsNull(rstRs![assigned apm]) Then
  APMName = ""
Else
  APMName = rstRs![assigned apm]
End If
... to ...
Code:
APMName = Nz(rst!AssignedAPM, "")
 

Users who are viewing this thread

Back
Top Bottom