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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter property on recordset

Status
Not open for further replies.

Kib

Programmer
May 17, 2001
58
US
Been having trouble getting a filter to work. How are they used. I am trying to do this :
I have a recordset that has multiple records anywhere from 2-30
and then a form, where the user selects a value from a listbox
I then want to filter the recordset to just the record with this value. Will always be unique
What I have now is this:
rsQUALIFIER.Filter = "[DDID]=" & Forms![SELECT QUALIFIER]!lstPARCEL
it is a number
but it does not seem to work. Do I have to turn the filter on or anything?
Thanks.

 
I am trying to filter the recordset, I believe the ApplyFilter command works for forms etc
I tried it, and at least thats what it seems to do.
Still trying to figure out why I can not filter the recordset.
Thanks though
 
From Access Help

Use the Filter property to apply a filter to a dynaset-, snapshot-, or forward-only–type Recordset object.
You can use the Filter property to restrict the records returned from an existing object when a new Recordset object is opened based on an existing Recordset object.
In many cases, it's faster to open a new Recordset object by using an SQL statement that includes a WHERE clause.

So basically you need to do something like this

Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.MoveLast
MsgBox rst.RecordCount
rst.Filter = "recordid = 1"
Set rst = rst.OpenRecordset(rst)
rst.MoveLast
MsgBox rst.RecordCount

you have to set the filter then open the recordset as it says you might be better off to use SQL

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top