Create temporary querydef and recordset

G

Guest

Hi,

I want to create a temporary recordset from a set of tables in which I can
modify the data.

I do the following:

Dim Db As Database
Dim Qr As QueryDef
Dim Rc As Recordset
....

Set Db = CurrentDb

SQL = "... etc ..."
Set Qr = Db.CreateQueryDef("", SQL)
Set Rc = Qr.OpenRecordset(dbOpenDynaset)

I get the error message "Error 3061 Too few parameters Expected 1..."
on the last line.

Please what am i doing wrong? Is there an easier way of doing what I am
trying?

Thanks
Kamil
 
V

Van T. Dinh

If your SQL String has a Parameter, you need to resolve the Parameter to
explicit value before passing to JET for processing.

One of the common traps is reference to a Form Control (which is a Parameter
as far as JET concerns). When you run Queries in Access, Access resolves
the reference / Parameter for you. However, when you use DAO code, Access
doesn't get involved and you have to code to resolve the Form Control
reference.
 
V

Van T. Dinh

You probably have both DAO and ADO Library in the References collection of
your database and ADO has higher priority in your References than DAO and
when you declared Rc, it defaults to ADO Recordset type which is not
compatible with DAO Recordset that you need.

Change the Dim statement to:

Dim Rc As DAO.Recordset
 

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