Opening a password protected form with the signed on user's record

J

Julio

Hi Guys, I need help please I've got this example code below which I pretty
much adjusted to work with my data base, it works ok it opens a password
protected form but it displays all records, I would like to open the form
with the record corresponding to the signed on user only.
The code below is in the Login command button in the "frmLogon" form
The form that contains the recods in question is "TimeCardEmployeeLogin"
Did that make any sense? I hope. Can you tell a I am very new at this ?

In advance thank you very much

Private Sub cmdLogin_Click()
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If

If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees",
"[lngEmpID]=" & Me.cboEmployee.Value) Then

lngMyEmpID = Me.cboEmployee.Value

DoCmd.Close acForm, "frmLogon", acSaveYes
DoCmd.OpenForm "TimeCardEmployeeLogin"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid
Entry!"
Me.txtPassword.SetFocus
End If

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database. Please contact
your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub

Thank you very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top