One question

atisz

Registered User.
Local time
Today, 12:48
Joined
Apr 5, 2005
Messages
96
Hi,

I have cboUser for choosing username, txtpassword for password input and this code, wich verify if the password is correct for selected user:

'Check value of password in tblUsers to see if this matches value chosen in combo box

If Me.txtpassword.Value = DLookup("Password", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) Then

lngMyEmpID = Me.cboUser.Value
'Things to do....


My question is: can this code be modify to verify also, if the user is an admin user or a simple user (I have this contained in tblUser's table UserType field), and if it is User open Form1, if it is Admin open Form2?
Any help apreciated.

Attila
 
Code:
If Me.txtpassword.Value = DLookup("Password", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) Then
    If DLookup("UserType", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) = "Admin" Then
         Do some admin stuff
    Else
         Do some other stuff
    End if
End if


???
 
KenHigg said:
Code:
If Me.txtpassword.Value = DLookup("Password", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) Then
    If DLookup("UserType", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) = "Admin" Then
         Do some admin stuff
    Else
         Do some other stuff
    End if
End if


???

Thank you!
It's great! :)))
But this drive me, somehow, in another problem. On the else I had a messagebox , in case the password wasn't right.
Now I modified the code this way:

If Me.txtpassword.Value = DLookup("Password", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) Then
If DLookup("UserType", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) = "Admin" Then
Do some admin stuff
Else
If Me.txtpassword.Value = DLookup("Password", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) Then
If DLookup("UserType", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) = "User" Then
Do some other stuff
Else
'MsgBox "Error message"
End if
End if
End if

but if the password is wrong both case, it didn't pop up the Msgbox.
What could be wrong?

Thankx
Attila
 
Did you mean to leave the comma in before the msgbox command?
 
KenHigg said:
Did you mean to leave the comma in before the msgbox command?

No, I didn't left the comma.
That way of course it can't work. I used the code without the comma.

Attila
 
Last edited:
Did you get this working? If not, cut and paste the code to a post. :)
 
Try This

Code:
If Me.txtpassword.Value = DLookup("Password", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) Then
If DLookup("UserType", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) = "Admin" Then
Do some admin stuff
ElseIf DLookup("UserType", "tblUsers", "[lngEmpID]=" & Me.cboUser.Value) = "User" Then
Do some other stuff
Else
'MsgBox "Error message"
Exit sub
End if
 
Thank you, guys!

Thanked to you now my form is working the way I want.

Attila
 

Users who are viewing this thread

Back
Top Bottom