Macro help using QueryDef

P

panoffp

I am using the following VB code to create a temp query.

' get cycleID from cycle Table
Set qdfC = dbs.CreateQueryDef("", _
"Select ID From Cycle where Cycle_Yr_Month = " & YrMon & _
" AND Cycle = " & Cyc & " ;")
Set rsC = qdfC.OpenRecordset(dbOpenSnapshot, dbReadOnly,
dbReadOnly)

When I execute the OpenRecord set command I get a Runtime Error: 3061. Too
few parameters, Expected 1.

I must be missing something in the explanations. Thank you in advance for
you time and suggestions!
 
D

Douglas J. Steele

What are the data types of Cycle_Yr_Month and Cycle? If either are text,
then the value you're passing must be enclosed in quotes.

BTW, macros don't use VBA in Access. You'd be better off posting questions
like this in microsoft.public.access.modulesdaovba.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)




I am using the following VB code to create a temp query.

' get cycleID from cycle Table
Set qdfC = dbs.CreateQueryDef("", _
"Select ID From Cycle where Cycle_Yr_Month = " & YrMon & _
" AND Cycle = " & Cyc & " ;")
Set rsC = qdfC.OpenRecordset(dbOpenSnapshot, dbReadOnly, dbReadOnly)

When I execute the OpenRecord set command I get a Runtime Error: 3061. Too
few parameters, Expected 1.

I must be missing something in the explanations. Thank you in advance for
you time and suggestions!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top