jgoodman00
Programmer
- Jan 23, 2001
- 1,510
I have the following code:
Function IDWork(strref) As String
Dim db As Database, rst As Recordset, rstAdopt As Recordset
Set db = currentdb
Set rst = db.OpenRecordset("SELECT Pnamstr.* FROM Pnamstr WHERE (((Pnamstr.RefNo) = '" & strref & "'));"
Set rstAdopt = db.OpenRecordset("SELECT ADOPT.* FROM ADOPT WHERE (((ADOPT.RefNo) = '" & strref & "'));"
If rstAdopt!priority <> "A" Then
IDWork = rstAdopt!RefNo & rstAdopt!brsno
Else
IDWork = Null
End If
End Function
The idea is that if the priority is A, the string IDWork will be null. This is passed back to the calling function. For some reason it is producing an error on the line 'IDWork = Null'. At this point, the error message is 'Invalid use of null'
This seems a little strange. It works if I change it into a zero length string, but I would rather pass out null.
Any suggestions??? James Goodman
j.goodman00@btinternet.com
Function IDWork(strref) As String
Dim db As Database, rst As Recordset, rstAdopt As Recordset
Set db = currentdb
Set rst = db.OpenRecordset("SELECT Pnamstr.* FROM Pnamstr WHERE (((Pnamstr.RefNo) = '" & strref & "'));"
Set rstAdopt = db.OpenRecordset("SELECT ADOPT.* FROM ADOPT WHERE (((ADOPT.RefNo) = '" & strref & "'));"
If rstAdopt!priority <> "A" Then
IDWork = rstAdopt!RefNo & rstAdopt!brsno
Else
IDWork = Null
End If
End Function
The idea is that if the priority is A, the string IDWork will be null. This is passed back to the calling function. For some reason it is producing an error on the line 'IDWork = Null'. At this point, the error message is 'Invalid use of null'
This seems a little strange. It works if I change it into a zero length string, but I would rather pass out null.
Any suggestions??? James Goodman
j.goodman00@btinternet.com