hi, i have two forms, Form A to login and enter Form B (provided that the logging in credentials are correct)
Form A has two fields (txtUserName and txtPassword)
what i want to do is, how do i 'filter' out the users that do not have sufficient access rights? (i.e. Advanced)
could i use the Dlookup function to look up in the table 'tblEmployee' for the field 'AccessRights', if so, how would i code it?
this is currently my code for the button in Form A that goes to Form B if the logging in credentials are correct:
Private Sub cmdGo_Click()
'Check to see if data is entered into the UserName combo box
Dim EmployeeID As Long
If IsNull(Me.txtUserName) Or Me.txtUserName = " " Then
MsgBox "Please enter your Username", vbOKOnly, "Required Username"
Me.txtUserName.SetFocus
Exit Sub
End If
If IsNull(Me.txtPassword) Or Me.txtPassword = " " Then
MsgBox "Please enter your password", vbOKOnly, "RequiredPassword"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this matches value chosen in combo box
If Me.txtPassword = DLookup("Password", "tblEmployee", "[EmployeeID]=" & Me.txtUserName) Then
EmployeeID = Me.txtUserName.Value
'Suggested code (i know it's wrong)
Exit Sub
End If
If EmployeeID = Dlookup("AccessRights","tblEmployee","[AccessRights]" = Advanced)
DoCmd.Close
DoCmd.OpenForm "Form B", acNormal
Else
MsgBox "Sorry, the username or password that you have entered is not correct, please try again", vbOKOnly, "Username/Password not correct"
Me.txtPassword.SetFocus
Exit Sub
End If
End Sub
help would be much appreciated and thanked
Form A has two fields (txtUserName and txtPassword)
what i want to do is, how do i 'filter' out the users that do not have sufficient access rights? (i.e. Advanced)
could i use the Dlookup function to look up in the table 'tblEmployee' for the field 'AccessRights', if so, how would i code it?
this is currently my code for the button in Form A that goes to Form B if the logging in credentials are correct:
Private Sub cmdGo_Click()
'Check to see if data is entered into the UserName combo box
Dim EmployeeID As Long
If IsNull(Me.txtUserName) Or Me.txtUserName = " " Then
MsgBox "Please enter your Username", vbOKOnly, "Required Username"
Me.txtUserName.SetFocus
Exit Sub
End If
If IsNull(Me.txtPassword) Or Me.txtPassword = " " Then
MsgBox "Please enter your password", vbOKOnly, "RequiredPassword"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this matches value chosen in combo box
If Me.txtPassword = DLookup("Password", "tblEmployee", "[EmployeeID]=" & Me.txtUserName) Then
EmployeeID = Me.txtUserName.Value
'Suggested code (i know it's wrong)
Exit Sub
End If
If EmployeeID = Dlookup("AccessRights","tblEmployee","[AccessRights]" = Advanced)
DoCmd.Close
DoCmd.OpenForm "Form B", acNormal
Else
MsgBox "Sorry, the username or password that you have entered is not correct, please try again", vbOKOnly, "Username/Password not correct"
Me.txtPassword.SetFocus
Exit Sub
End If
End Sub
help would be much appreciated and thanked