Opening a recordset

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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)
 
Oops! clicked post before I finished.
Another way is to filter the form:

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