Catching the Null Value

G

Guest

Hi

I’m trying to set a record set to my variables. In doing so I get an error
when there is a null value in the table. I’m trying to catch the null values
with the if then statement with no luck. Here is some of my code:

Dim strNewBankerName As String
Dim strSQL As String
Dim rst As Recordset
Dim dbs As Database

Set dbs = CurrentDb

strSQL = "SELECT Relationship_ID, Banker_ID, NewBankerID,
NewBankerIntranetID, NewBankerName FROM BankerReassignmentList;"

Set rst = dbs.OpenRecordset(strSQL)
rst.MoveFirst

If rst("NewBankerName") = Null Then
MsgBox "rst('NewBankerName') is Null"
Else
strNewBankerName = rst("NewBankerName")

End If

What can I do to catch the Null?

Thanks in advance,

Mark
 
T

T Martin

If isnull(rst!NewBankerName) = true then
msgbox "rst('NewBankerName') is null
Else
strNewBankerName = rst("NewBankerName")
End if
 
G

Guest

It works, Thanks T Martin

Mark

T Martin said:
If isnull(rst!NewBankerName) = true then
msgbox "rst('NewBankerName') is null
Else
strNewBankerName = rst("NewBankerName")
End if
 

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