OpenRecordset Error

S

Steve

Hi can any body tell me why this code works for a table but not for a query
please
this works for a table.
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblCustomer")
same code does not work for a query
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("qryCSVSingleSale")

I get an error no 3061 To few parameters. Expected 1.
I just want to loop through a record set that would be created by a query
but still allow others to use the records while this action is taking place.
and Im not sure how to go about it.
Help most apreceated
Steve - from a land down under
 
S

Steve

Roger the query works fine on its own and returns all the records I want
so what peram is missing
I would like it to be a snapshot so as to not to lockup the records for
other users.
I will be doing calculations that return results not change records.
but it works as a table but not as a query why?
Steve
 
S

Steve

I have found a solution to the broblem and will post here incase anybody else
encounters it.
It seems that when you use a query instead of a table you have to create the
parameters manualy with code. So here is what made my code work.

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim prm As Parameter
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs!qryCSVSingleSale
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rst = qdf.OpenRecordset()

I have no idea why realy but some kind person said try this and I did.
An explantion of whats happening would be helpful but Im unable to.
Steve - from a land down under
 

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