Error with Code

Mechele

Registered User.
Local time
Today, 04:58
Joined
Jan 25, 2002
Messages
121
If a user logs in the login form and they are a new employee, I want the employeeinfoform to open in data entry mode. If the user logs in and they are a current employee, I want the employeeinfoform to pull up their informaton from the employeeinfoquery. I'm getting a "too few parameters. Need one" error message at the following code:

Set rs = CurrentDb.OpenRecordset(StrSQL)

What am I missing?


Private Sub Command4_Click()

Dim StrSQL As String
Dim QDF As QueryDef
Dim rs As Recordset

StrSQL = "SELECT * from EmployeeInfoTbl WHERE EmployeeInfoTbl.Employee = Forms!LoginForm!employee"
Set QDF = CurrentDb.QueryDefs("EmployeeInfoQuery")
QDF.SQL = StrSQL
QDF.Close
Set rs = CurrentDb.OpenRecordset(StrSQL)
If rs.BOF And rs.EOF Then
DoCmd.OpenForm "EmployeeInfoForm"
Forms!EmployeeInfoForm.DataEntry = True
Else
DoCmd.OpenForm "EmployeeInfoForm"
Forms!EmployeeInfoForm.DataEntry = False
End If


End Sub
:mad:
 
Last edited:
Wrong
=====
StrSQL = "SELECT * from EmployeeInfoTbl WHERE EmployeeInfoTbl.Employee = Forms!LoginForm!employee"


Right
====
StrSQL = "SELECT * from EmployeeInfoTbl WHERE EmployeeInfoTbl.Employee = "
& "'" & Forms!LoginForm!employee & "'"


RichM
 
There is a problem with the code you provided. It turns the employee fields into a string fields and they are defined as a numeric field.
 

Users who are viewing this thread

Back
Top Bottom