Opening a recordset

G

Guest

I have been using the following command to open a recordset which contains
ALL of the records in a table called "Transactions":

Set rst = db.OpenRecordset("Transactions", dbOpenTable)

I want to modify this to only pull in records which match a certain
criteria; where the field "ReportID" equals a specific number, say 42.

What's the best/easiest way to do this?
 
G

Guest

Use a paramenter query instead of the table. Here is an example where I do
exaclty that:

Set qdfActual = dbs.QueryDefs("qselProjectChartsActual")
qdfActual.Parameters(0) = rstmaster![Mactivity]
Set rstActual = qdfActual.OpenRecordset(dbOpenSnapshot, dbReadOnly)

In the case above, my parameter is coming from a recordset
(rstmaster![Mactivity])
It can be a control on your form as well(Me.txtReportID)
 
G

Guest

Oops! clicked post before I finished.
Another way is to filter the form:

Me.Filter = "[ReportID = 42"
Me.FilterOn
 

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