Login Form Error (1 Viewer)

Djhilbert

Registered User.
Local time
Today, 00:19
Joined
Dec 26, 2011
Messages
17
Happy New Years to everyone

thanks for the help on my login security form. With all the help and changes i've made I'm now coming up with a Syntax error. This is my code so far.

Private Sub LOGIN_ID_FORM_Click()
Dim userlevel As Integer
Dim Userpassword As String
Dim Userlogin As String
Dim securityLVL As Integer

If IsNull(Me.txtLoginID) Then
MsgBox "Please Enter LoginID", vbInformation, "LoginID Required"
Me.txtLoginID.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please Enter Password", vbInformation, "Password Required"
Me.txtPassword.SetFocus
Else
'PROCESS JOB

If _ (this is the section that has a syntax error upto THEN)
( IsNuLL( _
DLookup( "[USERLOGIN]", "Login", "[USERLOGIN]= '" & Me.txtLoginID & "" )) _
OR _
( IsNull( _
DLookup( "[USERPASSWORD]", "Login", "[USERPASSWORD]= '" & Me.txtPassword & "" ))

Then

MsgBox "INVALID LOGIN ID OR PASSWORD"
Else
userlevel = (DLookup("[SecurityLVL]", "Login", "[UserLogin]= " & Me.txtLoginID & ""))
DoCmd.Close
If userlevel = 1 Then
'MsgBox "LOGIN ID AND PASSWORD ARE CORRECT"
DoCmd.OpenForm "ADMIN FORM"
Else
DoCmd.OpenForm "SPLASH PAGE"
End If
End If
End If
End Sub

on everyone's suggestion I changed the And to an OR I just hope when I get this working it will make sure both login and password are correct before going to the right form according to their security level. In case you need to know my table names are:

Login (table name)
field names USERID (auto), USERNAME (short text), USERLOGIN (short text), USERPASSWORD (short text), SecurityLVL (number), SecurityType (short text)

Thank You All for the Help. I'm sure I will have need of all of you when I set up the login tracking Thanks again
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 08:19
Joined
Jan 14, 2017
Messages
18,218
I've moved this to a new thread to increase the chances of it getting replies.
You mentioned previous help being given.
Suggest you add a link to the earlier thread in case anyone wants to refer back

Just a quick correction - you omitted several single quotes
I've changed IsNull to Nz but you can change that back if you wish

Code:
...
If Nz(DLookup("USERLOGIN", "Login", "USERLOGIN= '" & Me.txtLoginID & "[B][COLOR="Red"]'[/COLOR][/B]"),"")="" _
OR _
Nz(DLookup("USERPASSWORD", "Login", "USERPASSWORD= '" & Me.txtPassword & "[COLOR="red"][B]'[/B][/COLOR]"),"") Then 
    MsgBox "INVALID LOGIN ID OR PASSWORD"
Else
  userlevel = DLookup("SecurityLVL", "Login", "UserLogin= [COLOR="Red"][B]'[/B][/COLOR]" & Me.txtLoginID & "[COLOR="red"][B]'[/B][/COLOR]")
...
 
Last edited:

Djhilbert

Registered User.
Local time
Today, 00:19
Joined
Dec 26, 2011
Messages
17
I would like to thank everyone for the suggestions. With all the changes I'm happy to announce that my security login in form now WORKS. Thank you all again. Now time to set up the login tracking.
Djhilbert
 

isladogs

MVP / VIP
Local time
Today, 08:19
Joined
Jan 14, 2017
Messages
18,218
Excellent. Good luck with the next part
 

Users who are viewing this thread

Top Bottom