finding a record from an inputbox

B

Beards

I have a table "employee" and a field [userid]. When the application starts
an inputbox appears and asked the user ot enter their userid. Currently I
take the value entered and use it as a filter and that works great. However,
I want to come back with an error message if the userid entered is not found
in the table. Please help.

Chris
 
D

Dennis

If IsNull(DLookup("UserId","YourTable")) then
Msgbox "User does not exist"
else
' continue with filter as now
end if
 
B

Beards

Dennis, the value I am looking for is in the inputbox var MyValue, I want to
search for the value in the field Userid in the table employee. I can not
get your code to work. any idea

Dennis said:
If IsNull(DLookup("UserId","YourTable")) then
Msgbox "User does not exist"
else
' continue with filter as now
end if

Beards said:
I have a table "employee" and a field [userid]. When the application starts
an inputbox appears and asked the user ot enter their userid. Currently I
take the value entered and use it as a filter and that works great. However,
I want to come back with an error message if the userid entered is not found
in the table. Please help.

Chris
 
D

Dennis

The DLookUp should look like this (assuming UserID is numeric)
DLookUp("UserID","Employee","UserID = " & Val(MyValue))
If UserID is text then it should look like this
DLookUp("UserID","Employee","UserID = '" & MyValue & "'")

Beards said:
Dennis, the value I am looking for is in the inputbox var MyValue, I want to
search for the value in the field Userid in the table employee. I can not
get your code to work. any idea

Dennis said:
If IsNull(DLookup("UserId","YourTable")) then
Msgbox "User does not exist"
else
' continue with filter as now
end if

Beards said:
I have a table "employee" and a field [userid]. When the application starts
an inputbox appears and asked the user ot enter their userid. Currently I
take the value entered and use it as a filter and that works great. However,
I want to come back with an error message if the userid entered is not found
in the table. Please help.

Chris
 
Top