(Q) How can I filter a recordset based on a criteria?
(A) Use the Filter property of a recordset to limit it's record and
then open another new recordset on it.
For example, in the sub sFilterRS, I'm
limiting rs2 to a single record by setting a filter on rs1.
Sub sFilterRS()
Dim db As Database, rs1 As Recordset
Dim rs2 As Recordset
Set db = CurrentDb
Set rs1 = db.OpenRecordset("Select * from tblRuns")
rs1.Filter = "RunID=4"
Set rs2 = rs1.OpenRecordset
MsgBox rs2.RecordCount
Set rs2 = Nothing: Set rs1 = Nothing
Set db = Nothing
End Sub
|