Error 3075 (missing operator) help (1 Viewer)

12asd

Registered User.
Local time
Today, 10:29
Joined
Dec 11, 2017
Messages
15
I'm working on a login form but I can't seem to get the vba code to work.

The main part of the code I'm using is:
If (IsNull(DLookup("Access level", "TBL Accounts", "Username = '" & Me.TXT_Username & "'"))) And (IsNull(DLookup("Access level", "TBL Accounts", "Password = '" & Me.TXT_Password & "'"))) Then
MsgBox "Incorrect username and password.", vbOKOnly

The code that gets the error is:
If (IsNull(DLookup("Access level", "TBL Accounts", "Username = '" & Me.TXT_Username & "'"))) And (IsNull(DLookup("Access level", "TBL Accounts", "Password = '" & Me.TXT_Password & "'"))) Then
with the error:
Syntax error (missing operator) in query expression 'Access level'. I'm not even entirely sure what this means or how to fix it, I don't know what the missing operator is, I'm pretty sure I typed it correctly.
 

JHB

Have been here a while
Local time
Today, 11:29
Joined
Jun 17, 2012
Messages
7,732
Try to surround the field name and the table name with [] in all places.
Code:
[B][COLOR=Red][[/COLOR][/B]Access level[B][COLOR=Red]]
[/COLOR][/B][B][COLOR=Red][[/COLOR][/B]TBL Accounts[B][COLOR=Red]][/COLOR][/B]
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:29
Joined
Feb 19, 2013
Messages
16,553
you can do this with one dlookup

Code:
If IsNull(DLookup("Access level", "TBL Accounts", "Username = '" & Me.TXT_Username & "' AND Password = '" & Me.TXT_Password & "'")) then

your error usually means it cannot find something - in this case a field called 'access level'. Note that it is recommended you do not use spaces in field and table names - they can cause unexpected errors, but if you do, they need to be surrounded with square brackets i.e. use "[Access Level]" - and "[TBL Accounts]"

It doesn't help that Level is a reserved word, so using this in combination with spaces in names can generate misleading errors.
 

12asd

Registered User.
Local time
Today, 10:29
Joined
Dec 11, 2017
Messages
15
you can do this with one dlookup

Code:
If IsNull(DLookup("Access level", "TBL Accounts", "Username = '" & Me.TXT_Username & "' AND Password = '" & Me.TXT_Password & "'")) then

I know about that, it is just that I wasn't sure how to properly write that.
 

Users who are viewing this thread

Top Bottom