MS VB Run-time error '3075':

Hello,

I am new at ALL of this. My question; what is wrong with this code (if anything) or what process can I use to determine the root of my error

MS VB Run-time error '3075':
Syntax error (missing operator) in query expression 'tbl2EmployeesTypes1= AND FormName='frmLogin".
 
This is the code:

Private Sub Form_Load()
    If DLookup("HasAccess", "mainForm", "tbl2EmployeeTypes1=" & TempVars("EmployeeTypes1") & " AND FormName='" & Me.Name & "'") = False Then
    MsgBox "You do not have the IMHS Credentials to advance. Your request will terminate!"
    DoCmd.Close acForm, Me.Name
   
    End If

Thanks for all the help

Lawrence aka Bishop The error
Lawrence LevyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
it seems that

TempVars("EmployeeTypes1") 

is returned with empty value. can u diagnose it?
Lawrence LevyAuthor Commented:
I do not know how to diagnose it. I downloaded the solution "How to manage user access in access 2013". I would like a simple way to keep some users from some forms.
hieloCommented:
Put an apostrophe to the right of:
tbl2EmployeeTypes1=

And also the the left of AND:
If DLookup("HasAccess", "mainForm", "tbl2EmployeeTypes1='" & TempVars("EmployeeTypes1") & "' AND FormName='" & Me.Name & "'") = False Then
    MsgBox "You do not have the IMHS Credentials to advance. Your request will terminate!"
    DoCmd.Close acForm, Me.Name
End If

Open in new window


If TempVars is required, the do a check first:
If "" = CStr(TempVars("EmployeeTypes1")) Then
  MsgBox "Employee Type is required"
Else
     If DLookup("HasAccess", "mainForm", "tbl2EmployeeTypes1='" & TempVars("EmployeeTypes1") & "' AND FormName='" & Me.Name & "'") = False Then
        MsgBox "You do not have the IMHS Credentials to advance. Your request will terminate!"
        DoCmd.Close acForm, Me.Name
     End If
End If

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lawrence LevyAuthor Commented:
Thank you for the advice. I am no longer at work. I will let you know as soon as I return in the AM.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.