We help IT Professionals succeed at work.
Get Started

SQL Parameters run-time 3061

dschrishuhn
dschrishuhn asked
on
483 Views
Last Modified: 2021-04-21
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



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

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE