Hello Experts.
Coul you please help me to fix my program.
I created a login from with 2 levels. Admin an User.
If Admin login will open A form
and If User login will open B form
I had table tblAdmins
EmpID
EmpName
EmpPassword
Access field for Admin and User Level
Here is the code
[CODE=vb]Private Sub cmdLogin_Click( )
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEm ployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee. SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPa ssword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword. SetFocus
Exit Sub
End If
'Check value of password in tblAdmins to see if this matches value chosen in combo box
If Me.txtPassword. Value = DLookup("EmpPas sword", "tblAdmins" , "[EmpID]=" & Me.cboEmployee. Value) Then
lngMyEmpID = Me.cboEmployee. Value
End If
'Open correct form
Dim strAccessLevel As String
strAccessLevel = DLookup("[Access]", "tblAdmins" , "[EmpID]=" & Me.cboEmployee. Value)
If strAccessLevel = "Admin" Then
DoCmd.OpenForm "A"
Else
If strAccessLevel = "User" Then
DoCmd.OpenForm "B"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword. SetFocus
Exit Sub
End If
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempt s = intLogonAttempt s + 1
If intLogonAttempt s > 3 Then
MsgBox "You do not have access to this database. Please contact your system administrator." , vbCritical, "Restricted Access!"
Application.Qui t
End If
End Sub
[/CODE]
I tried but could not. Please help.
Thanks in advance
Coul you please help me to fix my program.
I created a login from with 2 levels. Admin an User.
If Admin login will open A form
and If User login will open B form
I had table tblAdmins
EmpID
EmpName
EmpPassword
Access field for Admin and User Level
Here is the code
[CODE=vb]Private Sub cmdLogin_Click( )
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEm ployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee. SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPa ssword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword. SetFocus
Exit Sub
End If
'Check value of password in tblAdmins to see if this matches value chosen in combo box
If Me.txtPassword. Value = DLookup("EmpPas sword", "tblAdmins" , "[EmpID]=" & Me.cboEmployee. Value) Then
lngMyEmpID = Me.cboEmployee. Value
End If
'Open correct form
Dim strAccessLevel As String
strAccessLevel = DLookup("[Access]", "tblAdmins" , "[EmpID]=" & Me.cboEmployee. Value)
If strAccessLevel = "Admin" Then
DoCmd.OpenForm "A"
Else
If strAccessLevel = "User" Then
DoCmd.OpenForm "B"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword. SetFocus
Exit Sub
End If
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempt s = intLogonAttempt s + 1
If intLogonAttempt s > 3 Then
MsgBox "You do not have access to this database. Please contact your system administrator." , vbCritical, "Restricted Access!"
Application.Qui t
End If
End Sub
[/CODE]
I tried but could not. Please help.
Thanks in advance
Comment