Thread: Filter help

    #1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Sep 2011
    Posts
    26
    Rep Power
    0

    Filter help


    Hello,

    My situation - I have a form [frmReport] which has a subform [frmSubReport] which is set to datasheet view. The subform displays select data from all records, I did attempt to use a listbox, but found that the subform setup is easier for sorting & filtering.

    My issue is this, I have a print button on the form which when clicked I want to display my report with the all records or if a filter is applied display to filtered records. I'm using to following code:

    Code:
    Private Sub cmdPrintPreview_Click()
    DoCmd.OpenReport "rptRequestSummary", acViewPreview, , Me.frmSubReport.Form.Filter
    End Sub
    It does work however when I apply a filter and close the report, the next time I go to run a report say of all the records the previous filter is still there. What am I missing?

    Sorry if this is basic but I'm pretty new to this and don't know the ins and outs of VBA, I'm still pinching and modifying code off the net.

    I'm using 2007 if that makes a difference.

    Many thanks.
  2. #2
  3. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Jun 2011
    Location
    South Jersey
    Posts
    544
    Rep Power
    59
    In access it's always good practice to destroy what you create. In this case the filter. Try me.frmsubreport.form.filteron = false after you close your report (perhaps in the close event of the report.) You may have to tinker with it to get it to work for application but hopefully this gives you the right idea.
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Sep 2011
    Posts
    26
    Rep Power
    0
    Thanks Meratigoerr,

    I ended up using Forms.frmReports.frmSubReport.Form.Filter = "" on the on close event on the report which so far does the job well.

    Ps. Thanks for the tip on destroying what you create, something I never really thought about.

Similar Threads

  1. How to filter in ASP?
    By myBoy in forum ASP Development
    Replies: 4
    Last Post: March 6th, 2009, 04:10 AM
  2. Filter?
    By TheZep in forum ASP Development
    Replies: 1
    Last Post: June 14th, 2006, 05:53 PM
  3. .Filter contains?
    By pgfconsultant in forum Microsoft Access Help
    Replies: 1
    Last Post: May 18th, 2005, 06:36 AM
  4. ASP Filter
    By Shenniko in forum ASP Development
    Replies: 6
    Last Post: September 27th, 2004, 10:11 AM
  5. Filter or not to filter
    By Steve Schofield in forum SQL Development
    Replies: 0
    Last Post: May 4th, 2001, 06:24 AM

IMN logo majestic logo threadwatch logo seochat tools logo