dschrishuhn
asked on
SQL Parameters run-time 3061
Hello,
In VBA, I'm trying to open a DAO recordset. I got Run-time error 3061 "Too Few Parameters. Expected 1". So I added a parameters clause
"PARAMETERS [ID] string; " _
To the SQL string. Now I get "...Expected 2" --??
qryOpenAgedReq is a Union:
SELECT * FROM tblAgedInvoicesIDFix UNION ALL SELECT * FROM tblRequestedInvoicesIDFix;
Both table have identical fields.
Thanks in advance!
-Omar
In VBA, I'm trying to open a DAO recordset. I got Run-time error 3061 "Too Few Parameters. Expected 1". So I added a parameters clause
"PARAMETERS [ID] string; " _
To the SQL string. Now I get "...Expected 2" --??
qryOpenAgedReq is a Union:
SELECT * FROM tblAgedInvoicesIDFix UNION ALL SELECT * FROM tblRequestedInvoicesIDFix;
Both table have identical fields.
Thanks in advance!
-Omar
Dim db As DAO.DATABASE
Dim SQL As String
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Set db = CurrentDb()
SQL = "PARAMETERS [ID] string; " _
& "SELECT PO, AP_Vendor, Vendor_Name, User_ID_Assigned " _
& "FROM qryOpenAgedReq " _
& "Where qryOpenAgedReq.ID = " & ID & ";"
Set qdf = db.CreateQueryDef("", SQL)
Set rst = qdf.OpenRecordset
ASKER
That was how my code looked originally. When I run it like that I get "Run-time error ' 3061': Too few parameters. Expected 1."
When I added the PARAMETER clause, I got the same error except "Expected 2"
When I added the PARAMETER clause, I got the same error except "Expected 2"
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
It was a string. Adding quotes did the trick. Thanks for your help!
-Omar
-Omar
Cheers, Andrew
Open in new window