Help:Open specific record in form from Login

plditch

New member
Local time
Today, 04:26
Joined
Aug 20, 2013
Messages
1
UNSOLVED MYSTERY
I have been trying for weeks to get my login form to open up to a specific record on the mainform. I have built a form out of my Employee tbl (mainform). The table stores (ID,Name, password, EmpNumber ect.) I built a subform in that allows the user to type in the number of overtime worked on a paticular day. I have disabled the navigation on the main form so users can't advance to the next user but have enable the natigation on the subform so a particular user can advance to the next week of available overtime to input data.

I am attaching the file. The goal is to get user login form to display a particular record on the main form and open a different form in the user is a supervisor.
Option Compare Database
Private intLogonAttempts As Integer
Private Sub cmdExit_Click()
DoCmd.Quit
End Sub
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
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
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) 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 tblEmployees to see if this matches value chosen in combo box
If Me.txtPassword.Value = DLookup("EmpPassword", "tblEmployeesLog", "[EmpID]=" & Me.cboEmployee.Value) Then
MyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen

DoCmd.Close acForm, "frmLogin", acSaveNo
DoCmd.OpenForm "frmEmpOt"
Else
MsgBox "Password Invalid. Please Try Again", vbCritical + vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User Enters incorrect password 3 times database will shutdown

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
 

Attachments

Welcome to the Forum, I have adjusted the code for you and it is now working, I have also made Login form display when the database is opened.

This is the extra code

'Close logon form and open splash screen
Dim strWhereCondition As String
If Me.Dirty = True Then
Me.Dirty = False
End If
strWhereCondition = "EmpID = " & Me.cboEmployee.Column(0)
Debug.Print strWhereCondition
DoCmd.OpenForm "frmEmpOt", , , strWhereCondition
 

Attachments

Hello experts
 

Users who are viewing this thread

Back
Top Bottom