[Msoft Access]Error with running code for DLookup
I have a problem with Microsoft access for code I have written to lookup the USER TYPE field in the ADMINSTRATOR TABLE.It is not able to run due to syntax error 3075 missing expression operator in query expression 'USER TYPE' It is used for my login menu to differentiate between two different user types and bring them to different forms. The code works before I implemented the User Security code Dim UserLevel As Integer UserLevel = DLookup("USER TYPE", "ADMINSTRATOR TABLE", "USER ID = '" & Me.txtLoginID & "'") Here is my code: Private Sub Command1_Click() Dim UserLevel As Integer If IsNull(Me.txtLoginID) Then MsgBox "Please enter Login ID", vbInformation, "Login ID Required" Me.txtLoginID.SetFocus ElseIf IsNull(Me.txtPassword) Then MsgBox "Please enter Password", vbInformation, "Password Required" Me.txtPassword.SetFocus Else If (IsNull(DLookup("[User ID]", "ADMINSTRATOR TABLE", "[User ID]='" & Me.txtLoginID.Value & "' And Password = '" & Me.txtPassword.Value & "'"))) Then MsgBox "Incorrect Password or Login ID", vbInformation, "Login unsuccessful" Else UserLevel = DLookup("USER TYPE", "ADMINSTRATOR TABLE", "USER ID = '" & Me.txtLoginID & "'") DoCmd.Close If UserLevel = 1 Then MsgBox "Login Success", vbInformation, "Login Success" DoCmd.OpenForm "MAIN MENU" Else MsgBox "Login Success", vbInformation, "Login Success" DoCmd.OpenForm "ADMINISTRATOR FORM" End If End If End If End Sub
Field names and table names containing spaces or special characters (poor design choice) need to surrounded with square brackets.
Is it possible to print a query through a form in MS Access?
Where is the Form/Report `Menu` event (that relates to OnMenu) defined in Access?
Access VBA DLookup: Syntax error (missing operator) in query expression
MS Access - Speed Issue
MS Access 2016 - Updating Multiple Tables
Concatenated numbers stuck in scientific notation MS Access
ms access for each field
in access how to draw tables on Report and then export it on word
Automatically adding ID number from different table to new entries?
Access VBA Outlook MAPI- Prevent Record Update if email is not sent
data type mismatch error in criteria expression-ms access
Access Main Form 'Enter Parameter Value'
How to get a combobox2 to display records only relating to the selection made in combobox1?
Ms Access: Running an update query
Access Query that brings up decimal amounts
Access 2016 Processes not being killed during Automation but same works for Access 2013/10/07