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.
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.