Fabian Julian
Fabian Julian

Reputation: 17

Type mismatch - VBA - Microsoft access

Please help. I am trying to validate the username and password from another table. The below code gives me "Type mismatch error". I have no idea why. Please help.

If (DLookup("[UserLogin]", "Sheet1", _
 "[UserLogin] ='" & Me.txtloginid.Value & "' And [Password] = '" & Me.txtpassword.Value & "'")) Then

Upvotes: 0

Views: 44

Answers (1)

Gustav
Gustav

Reputation: 55921

This will happen if UserLogin is numeric.

Also, don't rely on Null values for logic operations:

If Not IsNull(DLookup("[UserLogin]", "Sheet1", _
    "[UserLogin] = " & Me.txtloginid.Value & " And [Password] = '" & Me.txtpassword.Value & "'")) Then

Upvotes: 1

Related Questions