Hi,
I created a user login form for my database.
Please see code below.
The below code works fine, howver what i now need to add is a way to only bring up the relative data for the user logging in.
In tbleSuper i have Username, Password and Department.
When the users logs in I need it to only bring up the data for their department. I have already set up the relationship if necessary
Private Sub Command7_Click()
If IsNull(Me.Combo5) Or Me.Combo5 = "" Then
MsgBox "You must enter a UserName.", vbOKOnly, "Required Data"
Exit Sub
End If
If IsNull(Me.Text2) Or Me.Text2 = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Requierd data"
Me.Text2.SetFocus
Exit Sub
End If
If Me.Text2.Value = DLookup("strPassword", "tblSuper", "[ID]=" & Me.Combo5.Value) Then
ID = Me.Combo5.Value
DoCmd.Close acForm, "Form1", acSaveNo
DoCmd.OpenForm "tblUsers"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.Text2.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Thank you