Dlookup quirk

MrAustin

Registered User.
Local time
Today, 08:19
Joined
Oct 4, 2004
Messages
32
Hey all,

I'm unsure as to how to catch this error -- when using a dlookup function to find a user_id to match up records in another dlookup function, it works fine unless there is no record to match.

Here is the line:

intUserID = DLookup("[user_id]", "[tblUsers]", "[user_login] = '" & strProvidedLogin & "'")

Now that will work fine if the strProvidedLogin matches something in the tblUsers table, but produces an Invalid Use of Null error if there is no match. How do I get around this?

I'm trying to make my own login form from scratch :)

Thanks!
 
Use NZ to zero the null value
eg:-
intUserID = NZ(DLookup("[user_id]", "[tblUsers]", "[user_login] = '" & strProvidedLogin & "'"))

If intUserID = 0 then msgbox "Invalid":' do something else

Hope that helps

Paul
 
Yes, sorry my post assumed intUserID was an integer
 

Users who are viewing this thread

Back
Top Bottom