Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Recordset.clone help

Posted on 2006-04-24
6
Medium Priority
?
1,339 Views
Last Modified: 2008-01-16
I'm doing a clone of a recordset using set newRS = me.recordset.clone.  I'm then setting the filter for the cloned recordset which works fine.  The problem occurs when I try to turn the filter on.  I get an error message saying "Object doesn't support this property or method".  Why am I able to set a filter for the cloned recordset but not turn the filter on?  Is this possible and I'm just doing something wrong?  



Set newRS = Me.Recordset.Clone
    If newRS.RecordCount > 0 Then
        MyBookMark = newRS.Bookmark

        newRS.Filter = MyFilter
        newRS.FilterOn = True   'Error thrown here.
    End If
0
Comment
Question by:tim_cs
6 Comments
 
LVL 27

Assisted Solution

by:MikeToole
MikeToole earned 800 total points
ID: 16532170
The property you want is RecordsetClone - i.e.

Set newRS = Me.RecordsetClone
0
 
LVL 34

Assisted Solution

by:flavo
flavo earned 400 total points
ID: 16532247
There is no FilterOn method for a recordset (DAO or ADO)

Example using DAO:

    Dim rs As DAO.Recordset
   
    Set rs = Me.RecordsetClone
       
    With rs
        .Filter = MyFilter
        Set rs = rs.OpenRecordset
    End With

Dave
0
 
LVL 34

Expert Comment

by:flavo
ID: 16532251
err.. That should have been

  With rs
        .Filter = MyFilter
        Set rs = .OpenRecordset
    End With
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 800 total points
ID: 16532259
You need to set the filter in a recordset *before* opening a subsequent clone of it.
For example

    Dim rst As DAO.Recordset
    Dim rst2 As DAO.Recordset
   
    Set rst = Me.Recordset.Clone
   
    Debug.Print rst.RecordCount
    rst.Filter = MyFilter
   
    Set rst2 = rst.OpenRecordset
    rst2.Print .RecordCount


Should show a filtered recordcount for the second recordset (because the filter was set on the first one before opening).
You're almost always as well off opening a new recordset anyway - but based on a restricted SQL statement (i.e. with a WHERE clause).
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 16532263
Morning :-)
0
 
LVL 7

Expert Comment

by:SweetsGreen
ID: 16534088
there is no FilterOn

newRS.Filter = MyFilter '''turns on a filter
newRS.Filter = 0 ''turns off the filter
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question