Type mismatch error

Kurt

Well-known Member
Joined
Jul 23, 2002
Messages
1,664
I am getting a type mismatch error on this code:

Code:
    If (IsNull(DLookup("[UserName]", "tblUser", "[UserName]='" & Me.cboUser.Value & "'" And Password = "'" _
    & Me.txt_Password.Value & "'"))) Then

What am I doing wrong here?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
not positive but try changing

"[UserName]='" & Me.cboUser.Value & "'" And Password = "'" & Me.txt_Password.Value & "'")))
to
"[UserName]='" & Me.cboUser.Value & "' " And Password = "' " & Me.txt_Password.Value & "' ")))
 
Upvote 0
I think the problem is that the password check is also wrapped in the IsNull function. I think this would be more correct:
Code:
If (IsNull(DLookup("[UserName]", "tblUser", "[UserName]='" & Me.cboUser & "'")) And Password = "'" _
& Me.txt_Password & "'"))) Then
I left off .value since it is the default for text boxes and combo boxes. My suggestion is based on the assumption that the data type for the password and username fields is text.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,805
Messages
6,162,081
Members
451,738
Latest member
gaseremad

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top