Copy filtered recordset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • QueenKirsty
    New Member
    • Jul 2009
    • 14

    Copy filtered recordset

    I want to export data from forms to excel. I can do the export to excel bit if I can get a copy of the recordset.

    I have a form with a filter (that the user can turn on and off) and I want to copy only the filtered data to the duplicate recordset but when I do:

    Code:
    Set rs =  Me.Controls("SubMiscSiteAccess").Form.Recordset
    I get all the records not just the filtered ones. The filter being applied is:

    Code:
    me.filter = [sql statement here]
    me.filterOn
    Any suggestions on how to get a copy of just the filtered records?
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi QueenKirsty, and Welcome to Bytes!

    Use the RecordSetClone property of the form instead of the Recordset property. RecordSetClone reflects the underlying recordset as modified by any filters that have been applied.

    -Stewart

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      Sneaky!

      I never knew that :)

      Comment

      Working...