Runtime error 3075 in VBA (1 Viewer)

xyba

Registered User.
Local time
Today, 10:24
Joined
Jan 28, 2016
Messages
189
Hi

I wonder if someone could please point out why I'm getting this error when logging into my db:

Runtime Error 3705: Syntax error (missing operator) in query expression '[UserName]=Bob Smith'

When I select debug this is the code it highlights:

Code:
    If Me.TxtPassword.Value = DLookup("PWD", "tblUsers", _
            "[UserName]=" & Me.TxtUsername.Value) Then


I'm stumped as to what the issue is but it's probably something glaringly obvious.
 

missinglinq

AWF VIP
Local time
Today, 05:24
Joined
Jun 20, 2003
Messages
6,423
Presumably UserName is Text...then

"[UserName]=" & Me.TxtUsername.Value)

should be

"[UserName]='" & Me.TxtUsername.Value & "'")

Linq ;0)>
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:24
Joined
Sep 21, 2011
Messages
14,287
I would be comparing against other dLookups that I had already written that worked, like your dlookup for strID in your other thread for Login Form?
 

xyba

Registered User.
Local time
Today, 10:24
Joined
Jan 28, 2016
Messages
189
I would be comparing against other dLookups that I had already written that worked, like your dlookup for strID in your other thread for Login Form?

I've made a couple of changes to the db and it has, as I'd expected, thrown up a couple of issues.

Missinglinq's reply worked but now I'm getting an error with a tempvars.

What is wrong with this bit of code? I'm assuming my syntax for referencing a numerical value isn't correct?

Code:
If TempVars!CurrentLevel = 0 Then
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:24
Joined
Sep 21, 2011
Messages
14,287
Well it would help to say what error?:(
Is CurrentLevel defined as numeric?

What does
Code:
? vartype(Tempvars!CurrentLevel)
in the immediate window or with a debug print ?
 

xyba

Registered User.
Local time
Today, 10:24
Joined
Jan 28, 2016
Messages
189
Well it would help to say what error?:(
Is CurrentLevel defined as numeric?

What does
Code:
? vartype(Tempvars!CurrentLevel)
in the immediate window or with a debug print ?

Sorry :eek: it is a type mismatch error.

The code you gave returns 10.
 

Users who are viewing this thread

Top Bottom