Select Record

Mechele

Registered User.
Local time
Today, 13:04
Joined
Jan 25, 2002
Messages
121
Dim rec As Recordset
Dim db As Database
Dim StrSQL3 As String

StrSQL3 = "Select* From EnrollmentInformationTable WHERE (((EnrollmentInformationTable.EmployeeSSN)=[forms]![updateform]![temp]) AND ((EnrollmentInformationTable.EmployeeLastName)=[forms]![updateform]![name]));"
Set rec = CurrentDb.OpenRecordset(StrSQL3)
If rec.BOF And rec.EOF Then
MsgBox ("You did not type a valid last name and social security number."), vbCritical
Me.SSN.SetFocus
Else
Set QDF = CurrentDb.QueryDefs("EnrollmentFormUpdateQuery")
QDF.SQL = StrSQL3
QDF.Close
DoCmd.OpenForm "EnrollmentFormUpdate"
DoCmd.Close acForm, "UpdateForm"
End If

What's wrong with the above code. I'm getting the following error message:
"Too few parameters. Expected 2."

I always have a problem when I try to use the select record statements. :o
 
Mechele said:
StrSQL3 = "Select* From EnrollmentInformationTable WHERE (((EnrollmentInformationTable.EmployeeSSN)=[forms]![updateform]![temp]) AND ((EnrollmentInformationTable.EmployeeLastName)=[forms]![updateform]![name]));"


Should be....

StrSQL3 = "Select * From EnrollmentInformationTable WHERE EnrollmentInformationTable.EmployeeSSN = " & [forms]![updateform]![temp] & " AND EnrollmentInformationTable.EmployeeLastName = " & [forms]![updateform]![name]
 
Last edited:
I copied your code in to my module and I got the following error message:
"Two few parameters. Expected 1."

So I adjusted to this and I still get the same error message:

StrSQL3 = "Select * From EnrollmentInformationTable WHERE EnrollmentInformationTable.EmployeeSSN = " & [Forms]![updateform]![temp] & " AND EnrollmentInformationTable.EmployeeLastName = " & [Forms]![updateform]![EmployeeName] & ";"
 
Mechele said:
I copied your code in to my module and I got the following error message:
"Two few parameters. Expected 1."

So I adjusted to this and I still get the same error message:

StrSQL3 = "Select * From EnrollmentInformationTable WHERE EnrollmentInformationTable.EmployeeSSN = " & [Forms]![updateform]![temp] & " AND EnrollmentInformationTable.EmployeeLastName = " & [Forms]![updateform]![EmployeeName] & ";"

More than likely its because I forgot the hard coded Quotes

Code:
StrSQL3 = "Select * From EnrollmentInformationTable WHERE EnrollmentInformationTable.EmployeeSSN = " & chr(34) & [Forms]![updateform]![temp] & chr(34) & " AND EnrollmentInformationTable.EmployeeLastName = " & chr(34) & [Forms]![updateform]![EmployeeName] & chr(34)
 
Mechele,
Did this not work? What is the data type of the SSN field?
 
No, it didn't. So, I've been trying to code several different ways and I keep coming up with errors. All the fields are text fields.....
 

Users who are viewing this thread

Back
Top Bottom