Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DAO Open recordset which is a query

Status
Not open for further replies.

dyarwood

Programmer
Joined
Nov 3, 2003
Messages
1,483
Location
GB
Hi

I am using DAO to open recordsets in the following way

Dim db As Database
Dim rs As Recordset

Set db=CurrentDb
Set rs =db.OpenRecordset("my recordset")

My problem is that if "my recordset" is a table this works fine but I want to have the option of using this code for a query. Is there anyone who can advise me on where I am going wrong.

Cheers

dyarwood
 
A far as I can see, this should work fine on queries & SQL statements as well.

What error messages are you getting?

Dean.
 
It throws back an error saying "Too few paramenters. Expected 1". I have done a similar thing using ADODB but I am wanting to use DAO for this process. Does the version of Access affect the code I need to use?

Cheers

dyarwood
 
That error message means that the query you're trying to run has a parameter field, or more likely, an unknown field name or expression.

Try running that query from the query window and it should prompt you for a parameter.

You can specify parameters for a query before running it, but I think that can only be done with QueryDef objects.

Just make sure that there are no unknown fields. This will more than likely solve the problem.

Dean :-)

By the way did you sort that toolbar problem?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top