Query's, Recordsets and parameters

Smee

Registered User.
Local time
Today, 03:23
Joined
Dec 16, 2003
Messages
69
Hi again.

I've been using this line to link to recordsets :-

Code:
set rs = db.OpenRecordset("Rates")

So far it has worked fine, but they've all been tables.

I now need to do the same but with a query.

Code:
Set rs = db.OpenRecordset("Rates Query")

This query selects records depending on 2 values. When I try and run this code it gives the error message:-

Too few Parameters. Expected 2

What is the syntax for passing the required parameters. I've tried all the things I can think of and searched briefly for an answer on the boards but couldn't find one.

As always, help much apprieciated.

Thanks

Smee.
 
Code:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset

Set db = CurrentDb
Set qdf = db.QueryDefs("Rate Query")

qdf.Parameters(0) = [i]put your first parameter here[/i]
qdf.Paramerers(1) = [i]put your second parameter here[/i]

Set rs = qdf.OpenRecordset
 
Thanks both of you very much.

So incredibly fast with the answers. :eek:
 

Users who are viewing this thread

Back
Top Bottom