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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup help needed

Status
Not open for further replies.

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:

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?
 
Change this:
strHunterID = TABORT

To:
strHunterID = "TABORT"


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top