Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Time error 3061 1

Status
Not open for further replies.

IamCornholio

Programmer
Jan 26, 2007
16
US
I'm getting the evil error 3061. I typically find that I get this when I run SQL in code. My code is as follows...

[blue]
strSQL = "Select a.Supervisor "
strSQL = strSQL & "From tbl_PersonnelInformation a "
strSQL = strSQL & "Where Last_Name = " & Me.cboLastName & " "
strSQL = strSQL & "AND First_Name = " & Me.cboFirstName ' & "'"

Set db = CurrentDb()

Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
[/blue]

It keeps telling me its expecting two parameters. Would this be because I'm passing two combo box values to the query?

Any help is appreciated.
Thanks
Corn.
 
strSQL = strSQL & "Where Last_Name = " & Me.cboLastName & " "
strSQL = strSQL & "AND First_Name = " & Me.cboFirstName ' & "'"


Try enclosing Me.cboLastName in single quotes;
Get rid of the single quote in Me.cboFirstName '
Like this:

strSQL = strSQL & "Where Last_Name = '" & Me.cboLastName & "' "
strSQL = strSQL & "AND First_Name = '" & Me.cboFirstName & "'"

Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.
 
[blue]WOW......!!!!!! I mean WOW, thats wierd, but simple... wonder why its like that?[/blue]

Heres a star for ya CLICK!!!
 
SQL ikes its strings enclosed in single quotes. Go figure...
Glad it worked & thanks for the star!
A virtual cold beer back at ya!

[cheers]

Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top