Parameter error box

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
 
O

Ofer

What happen when you run the form but it self, without the command line?
Do you get the message to enter the employeeID?

It could be, that the problem is with the form, and not with the code.
Check the record source of the form, if its ask for a parameter.

--
Please respond to the group if your question been answered or not, so other
can refer to it.
Thank you and Good luck



Evan Goldin said:
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
 
R

RoyVidar

Evan Goldin wrote in message
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

Could it be this
http://support.microsoft.com/?id=811860
or one of the referred errors/flaws?
 
E

Evan Goldin

Hey all, just for future reference, I was able to figure out the problem by
tweaking the code some more. Here's the correct code for a login:

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 stLinkCriteria As String



stLinkCriteria = "[EmployeeID]= " & Me.cboEmployee.Value
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblemployees",
stLinkCriteria) Then


'Close logon form and open splash screen
DoCmd.OpenForm "NewDailyReport", , , "[Employee]= " & Me.cboEmployee.Value
DoCmd.Close acForm, "StartForm", acSaveNo


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


RoyVidar said:
Evan Goldin wrote in message
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

Could it be this
http://support.microsoft.com/?id=811860
or one of the referred errors/flaws?
 

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