keelingj
Programmer
- Oct 14, 2008
- 1
I'm trying to use DLookup to return a specific value from a table and store that value as a global variable. Here's what I have so far:
Query (Qry_LogoutToday) fields:
LogoutID (PK)
LogoutDate (today's today)
HunterID
Now for the code:
This is supposed to look through the query, find TABORT, and return his LogoutID for the current day. However, all I get is the following error: Run-time error '94': Invalid use of Null.
If I hard-code the HunterID, my code works just fine:
The simplified code returns the correct LogoutID in a MsgBox window without any errors.
Any idea how I can get it to work with the variable?
Query (Qry_LogoutToday) fields:
LogoutID (PK)
LogoutDate (today's today)
HunterID
Now for the code:
Code:
strHunterID = TABORT
strLogoutID = DLookup("LogoutID", "Qry_LogoutToday", "HunterID = '" & strHunterID & "'")
MsgBox (strLogoutID)
This is supposed to look through the query, find TABORT, and return his LogoutID for the current day. However, all I get is the following error: Run-time error '94': Invalid use of Null.
If I hard-code the HunterID, my code works just fine:
Code:
strLogoutID = DLookup("LogoutID", "Qry_LogoutToday", "HunterID = 'TABORT'")
MsgBox (strLogoutID)
The simplified code returns the correct LogoutID in a MsgBox window without any errors.
Any idea how I can get it to work with the variable?