E
Evan Goldin
Hi all,
I'm using a simple login form to access another form, but I'm running
into an error. Users enter their employeeID and password on the login page,
and then when they login it is supposed to bring them to another form (where
the records are filtered so they can only see the records where the
employeeID matches the one they just entered). However, using the current
code, an "Enter Parameter" pop-up box comes up after clicking the button, and
it asks me to enter the employeeID number. If I enter the employeeID number
that I have already entered on the login form, it takes me to the correct
form (and it seems as though the filter is on), but it isn't filtering the
results, it's still showing all forms, no matter the employeeID number.
However, if I enter a completely random, wrong number on the pop-up box, then
it takes me to the filtered form with NO old records. How should I proceed?
Is there something I'm missing? Code is as follows:
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
Dim strFilter As String
strFilter = "[EmployeeID]= " & Str(Me.cboEmployee)
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblemployees",
strFilter) Then
'Close logon form and open splash screen
DoCmd.OpenForm "NewDailyReport", , , "[employeeID]= " & Me.cboEmployee
DoCmd.Close acForm, "StartForm", acSaveNo
'This code is inactive, and it doesn't change anything when it is active:
'Dim stDocName As String
' Dim stLinkCriteria As String
' stDocName = "NewDailyReport"
' stLinkCriteria = "[Employee]=" & "'" & Me![cboEmployee] & "'"
'DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Password Invalid. Please Try Again", 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 admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
I'm using a simple login form to access another form, but I'm running
into an error. Users enter their employeeID and password on the login page,
and then when they login it is supposed to bring them to another form (where
the records are filtered so they can only see the records where the
employeeID matches the one they just entered). However, using the current
code, an "Enter Parameter" pop-up box comes up after clicking the button, and
it asks me to enter the employeeID number. If I enter the employeeID number
that I have already entered on the login form, it takes me to the correct
form (and it seems as though the filter is on), but it isn't filtering the
results, it's still showing all forms, no matter the employeeID number.
However, if I enter a completely random, wrong number on the pop-up box, then
it takes me to the filtered form with NO old records. How should I proceed?
Is there something I'm missing? Code is as follows:
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
Dim strFilter As String
strFilter = "[EmployeeID]= " & Str(Me.cboEmployee)
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblemployees",
strFilter) Then
'Close logon form and open splash screen
DoCmd.OpenForm "NewDailyReport", , , "[employeeID]= " & Me.cboEmployee
DoCmd.Close acForm, "StartForm", acSaveNo
'This code is inactive, and it doesn't change anything when it is active:
'Dim stDocName As String
' Dim stLinkCriteria As String
' stDocName = "NewDailyReport"
' stLinkCriteria = "[Employee]=" & "'" & Me![cboEmployee] & "'"
'DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Password Invalid. Please Try Again", 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 admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub