Parameter query

C

Crystal

I'm trying to set a query in code and then set it in a
recordset, so I can use the data. I have this:

Set qdef = db.CreateQueryDef("", _
"PARAMETERS dteStart DateTime, dteEnd
DateTime; " & _
" SELECT Sum(tblActivity.Good) AS
CoilUnitTotal" & _
" FROM tblActivity" & _
" WHERE (((tblActivity.WkKey)=4) AND
((tblActivity.ActDate) BETWEEN [dteStart] AND [dteEnd]))")

Set prmStart = qdef.Parameters!dteStart
Set prmEnd = qdef.Parameters!dteEnd
prmStart = WeekStart
prmEnd = WeekEnd
Set rstQuery = qdef.OpenRecordset()

MsgBox rstQuery!CoilUnitTotal


It doesn't work. It says: "Too few parameters. Expected
2"

I thought I gave it the two parameters. What am I doing
wrong?

Any help would be greatly appreciated,
Crystal
 

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