Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Use of Null ??

Status
Not open for further replies.

mishbaker

Technical User
Jan 17, 2004
94
US
I have this code in my form to check and see if a DOC# has already been used and return the ITEM# of the item it was assigned to if it has been used. Otherwise it should return a NULL value.

Code:
stDOCUsed = DLookup("[Item]", "PartsRequestData", "[DOC] = '" & Me![frmSUBAssignDocs].Form![txt1].Value & "'")

But everytime I run it I get the little box with "Invalid Use of Null" in it.

How is that an invalid use of null??? Is there a valid use??

All lessons learned from the School of Hard Knocks........at least tuition is cheap.
 
Code:
stDOCUsed = [b][COLOR=blue]Nz([/color][/b]DLookup("[Item]", "PartsRequestData", "[DOC] = '" & Me![frmSUBAssignDocs].Form![txt1].Value & "'")[b][COLOR=blue], " ")[/color][/b]

________________________________________
Zameer Abdulla
Visit Me
A child may not be able to lift too much.
But it can certainly hold a marriage together
 
You can't assign a NULL to a string variable in VBA.

Gary
gwinn7
A+,N+,L+,I+
 
ZmrAbdulla . . . . .

I believe its your intent to return an empty string:

Code:
 [purple][b]""[/b][/purple]  not [purple][b]" "[/b][/purple]

Calvin.gif
See Ya! . . . . . .
 
TheAceman1,Yes you are right.
But I have tested it and no error was there.
Thank you for notifying.

________________________________________
Zameer Abdulla
Visit Me
A child may not be able to lift too much.
But it can certainly hold a marriage together
 
ZmrAbdulla . . . . .
TheAceMan said:
[blue]My point is: Although Access converts spaces only text to a null string when a record is saved, [purple]while the record is dirty, a check for an empty string would fail![/purple][/blue]

Calvin.gif
See Ya! . . . . . .
 
I normally add Trim() if I need to test null string

________________________________________
Zameer Abdulla
Visit Me
A child may not be able to lift too much.
But it can certainly hold a marriage together
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top