ms-access


[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.

Related Links

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

Categories

HOME
testing
client
deployment
cplex
react-router
alfresco
adfs
medical
google-translate
quickbooks
google-cloud-ml
windows-azure-storage
phaser
decomposition
carthage
jsprit
serverless-framework
angular-ui
beyondcompare
plunker
amazonsellercentral
opencover
web-sql
kudan
microsoft-sync-framework
pepper
internet-explorer-9
windows-error-reporting
jspm
facebook-apps
atlassian-crucible
webkitspeechrecognition
bluestacks
galsim
http-status-code-503
catch-all
commit
picasso
gesture
jna
webdriver-manager
email-templates
fedex
quadratic-programming
glew
android-mediaprojection
eigenvalue
no-www
gpx
osx-mavericks
upstart
magma
nodebb
master-slave
design-by-contract
goose
two-factor-authentication
qtableview
feedback
muse
cakephp-3.1
processmodel
streambase
website-monitoring
ng-animate
c3
network-interface
rdtsc
websocket4net
openexr
tld
floating-point-precision
oam
spring-io
bulkloader
robotics-studio
word-processor
jspinclude
objective-c-2.0
code-cleanup
assembly-loading
nsobject
zpt
psi
invite
disclosure
gdlib
compiler-specific
nerddinner
uiq3

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App