Problem with Filter method recordset

T

Tiziano Ricci

Hello everyone
I have a problem using filter property of dao.recordset. It seems to be
ignored by Access 2007. I use Microsoft Office 12.0 Access database engine
Object Library.
Here is an example
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM Tabella1", dbOpenDynaset)
(Tabella1 contains 3 record)
rs.MoveLast
rs.MoveFirst
rs.Filter = "Id=1"

MsgBox rs.RecordCount
the result is --> = 3
May you help me?
Tiziano
 
A

Alex Dybenko

Ciao!
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.
so try:

dim rs2 As Recordset
rs.Filter = "Id=1"
rs2=rs.OpenRecordset
MsgBox rs2.RecordCount

In many cases, it's faster to open a new Recordset object by using an SQL
statement that includes a WHERE clause.


--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 

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