[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.
MS-Access library for performing many kinds of DDL operations on a database (to facilitate application version upgrades)?
How to Remove Stop Words from a string using Visual Basic?
Microsoft Access runtime error 2455 when trying to access grandchildren forms from child form
Microsoft Access - stored procedure with cursor
MS Access - Write to Table Immediately After Changing Value in Form
Unbind Access Project from source control
DAO access recordset not updating
No values given for one or more required parameters error only on some Windows 7 machines
In Memory, Stand-Alone, Disconnected ADO Recordset
Record-Locking in Access 10
How to force access to begin a new record
How should I setup Shipping and Receiving tables for RDBMS?
Remove link for linked table in access
MSACCESS 2002 Linked Table Performance Really Slow
ms access 2010 update linked table with no primary key
Memo field value truncated to about 1000 characters when inserted from a .net typed dataset