troubleshooting Question

simple question (i guess): assign different roles in access

Avatar of xaveboyz
xaveboyz asked on
Microsoft Access
14 Comments1 Solution293 ViewsLast Modified:
hai, i'm new access user and i want to create login form for my database, i have "user table" that contains user id, name, role and password, here is the sample:

id     name     role     pass
1       A       admin    1111
2       B       user     2222

in the form i have textbox for inserting pasword, 1 combobox to select username, and one more combobox for selecting user role

and this is my code inside the login form:

Private Sub cmdlogin_Click()
Static intpasswordcount As Integer

If Me!txtpassword = Me![cmbusername].Column(3) And Me!cmbuserrole = Me![cmbusername].Column(2) Then
DoCmd.OpenForm "frmwelcome", acNormal
Else
If Me!txtpassword = "" Then
    MsgBox "Please insert your password", vbCritical
Else
MsgBox "Incorrect password or wrong user role", vbCritical
End If
        intpasswordcount = intpasswordcount + 1
        If intpasswordcount = 3 Then
            DoCmd.Close acForm, Me.Name
        End If
        Exit Sub
End If

End Sub

the problem is everytime i pushed the enter button, an "incorrect password or user role" error message will come up.Actually what I want is if A enters the login page , the database must know that he is and "Admin", not "user", so though he has typed correct password but choose wrong role, he will be still kicked out..can somebody help me ??

thank you

ASKER CERTIFIED SOLUTION
YP

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros