How to differenciate the login as per the defined level

sarohap

Registered User.
Local time
Today, 01:58
Joined
Nov 10, 2012
Messages
14
Hi All Experts..

My new query is..i have user table to login in the database..
this is user login table

userid = autonumber
emp_id = number
empname = text
username = text
password = memo
role = text.

this is admin userlogin table

adminID = autonumber
adminname = text
adminpassword = memo

if anyone login from admin then form should be open ("EntryandReportfrm")
if anyone login from usertable then form should be open ("entryfrm")
both are as example name can be different in below given code.


i m using the code here to login the users but it did not make any difference. so please help on this one also..

Public Sub Login()

On Error GoTo ErrorHandler:
If IsNull([cbouser]) = True Then 'Check UserName
MsgBox "Username is required"
cbouser.SetFocus

ElseIf IsNull([txtpassword]) = True Then 'Check Password
MsgBox "Password is required"
txtpassword.SetFocus

Else

'Compare value of txtPassword with the saved Password in tblUser
If Me.txtpassword.Value = DLookup("Password", "tblUsers", "[UserName]='" & Me.cbouser.Value & "'") Then
strUser = Me.cbouser.Value 'Set the value of strUser declared as Global Variable
strRole = DLookup("Role", "tblUsers", "[UserName]='" & Me.cbouser.Value & "'") 'set the value of strRole declared as Global Variable
DoCmd.Close acForm, "login_form", acSaveNo
MsgBox "Welcome, " & strUser, vbOKOnly, "Welcome"
DoCmd.OpenForm "Training_Form", acNormal, "", "", , acNormal

Else
MsgBox "Invalid Password. Please try again.", vbOKOnly, "Invalid Password"
intLogAttempt = intLogAttempt + 1
txtpassword.SetFocus

End If

End If

'Check if the user has 3 wrong log-in attempts and close the application
If intLogAttempt = 3 Then
MsgBox "You do not have access to this database.Please contact admin." & vbCrLf & vbCrLf & _
"Application will exit.", vbCritical, "Restricted Access!"
Application.Quit
End If
:):):):)
 
Before you continue you along this route -- I strongly encourage you to forget about complicated un/pw application login tables and simply include a list of usernames.

To keep it simple, you could use table fields: username / type
ie.
"john smith", "user"
"GOD", "admin"

Now use the environ() command to use the windows login usernames.

if environ("username") = username then docmd.openform "userform"
if environ("username") = adminusername then docmd.openform "adminform"


There are serious security issues associated with including passwords in static tables.
 
Please could you explain that how to use this condition...?

Please send me your mail id so i can send you the sample database...
 

Users who are viewing this thread

Back
Top Bottom