Problem with coding User login form in ACCESS 2013

chriss_ko

Registered User.
Local time
Today, 08:28
Joined
Mar 26, 2013
Messages
28
I have a table called User (user_ID, User_Name, Password, Security_Level)
On form there is a combo box for user name and text box for password.
Two command button where one is for EXIT (Closing the application) and the second button is to run the code.

if the password in table User matches value chosen in combo box or user name and password are correct
Then it should check if Security_Level of the user is equal to 1 to displays a form called Admin
and when the Security_Level of the user is equal to 2 to display a form called user1.

NOTE: All that I want is to have a login that has two user and each user when login opens his/her own form which is different from the other user.

Plzz help me to write codes for this. Am not good at coding.
I will appreciate for any assistance & support.
Thanx, Chriss.
TANZANIA.
 
Hello Chriss, Welcome to AWF.. :)

This thread is dedicated to Introductions only, I will ask one of the moderators to move this for you..

However regarding your Query.. This thread might give you some pointers.. I have put up a small sample in Post #8, that might be of interest to you..
 
Thanks a lot but i didn't see the solution for this one and it is the big problem i am facing now;

I have used Combo box. security_level field is the one that describes their levels and there are only two levels 1 and 2... My design is like this …. Below…
I have a table called User (user_ID, User_Name, Password, Security_Level)
On form there is a combo box for user name and text box for password.
Two command button where one is for EXIT (Closing the application) and the second button is to run the code.

if the password in table User matches value chosen in combo box or user name and password are correct
Then it should check if Security_Level of the user is equal to 1 to displays a form called Admin
and when the Security_Level of the user is equal to 2 to display a form called user1.

NOTE: All that I want is to have a login that has two user and each user when login opens his/her own form which is different from the other user.
 
Then it should check if Security_Level of the user is equal to 1 to displays a form called Admin
and when the Security_Level of the user is equal to 2 to display a form called user1.
Hello chriss_ko, if you have noticed the code, after Authentication you will have something like..
Code:
DoCmd.OpenForm "formName"
Now all you need to do it add another DLookUp to get the Security Level..
Code:
Dim accessLvlStr As String
accessLvlStr = Nz(DLookUp("[COLOR=Blue]securityLevelField[/COLOR]","[COLOR=Blue]tableName[/COLOR]","[COLOR=Blue]ConditionToCheck[/COLOR]"), "Admin")
If accessLvlStr = "Admin"
    DoCmd.OpenForm "AdminForm"
Else
    DoCmd.OpenForm "UserForm"
End If
The above is just a psuedo code.. Change the blue bits to match your design.. Hope this helps..
 
Thanks a lot for the support but i didn't understand. i tried this code may you take a look and tell me whats the problem because it brings error.
Thanks very much for your support,
but it brings this error.
"run time error 3075
syntax error (missing operator) in query operation 'user_id='.

Private Sub Command9_Click()

Dim PasswordLookup As String
Dim SecurityLevelLookup As Integer

PasswordLookup = Nz(DLookup("Password", "User", "user_id=" & Nz(MyUserID, 0)), 0)
SecurityLevelLookup = Nz(DLookup("Security_Level", "User", "User_ID=" & Nz(MyUserID, 0)), 0)

If PasswordLookup = MyPassword And SecurityLevelLookup = 1 Then
DoCmd.OpenForm "Admin", acNormal
Else

If PasswordLookup = MyPassword And SecurityLevelLookup = 2 Then
DoCmd.OpenForm "User1", acNormal
Else

End If
End If
End Sub
 
Please do not DOUBLE POST.. Am sorry to say this, but it is getting on my nerve, a bit..
I have also answered your question in the other thread.. :mad:

Syntax error mostly signifies that you are comparing a String to a Number.. Show the code you have written,along with the field types of your table..
 
Thank you very much it has worked, thanks again.
Asante sana.
 
Is it possible to display a msg when a user didn't write the user name to display a msg saying ENTER USER NAME and when he forgets to write password to say write password and when its wrong password to say incorrect password or user name.???
 

Users who are viewing this thread

Back
Top Bottom