Results 1 to 4 of 4
  1. #1
    VariableZ's Avatar
    VariableZ is offline Partially Knowledgeable
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    Georgia, USA
    Posts
    40

    Filter Resets On Print Preview Due To On Open Event

    I'm trying to open a report and have it filter to only show the last 15 days of input, so I wrote the following under the On Open event:

    Private Sub Report_Open(Cancel As Integer)
    Me.Filter = "[DATE RECORDED] >= #" & Date - 15 & "#"
    Me.FilterOn = True
    End Sub



    I'll call this the 'automatic' filter.
    It works, and I can filter by other fields manually without a problem.
    Unfortunately, every time I go to Print Preview, the On Open event _seems_ to be triggered, and all my sorts go back to default... at least visually. The filter I manually applied is still listed under Advanced Filter/Sort, and if the filter I applied is on [DATE RECORDED], it becomes obvious that the automatic filter is not there. If I then filter by any other field, the previous manual filter is activated again, as well as any filter I just applied.

    Does anyone have an idea what I'm doing wrong? I tried putting the filter in the On Load event, but then it _actually_ resets the filter on Print Preview instead of just _seeming_ to.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Reports are not really intended to be interactive, that's what forms are for. Yes, the Open event runs when switching to PrintPreview even if report already open. Never known anyone to try printing report with manual filter.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    VariableZ's Avatar
    VariableZ is offline Partially Knowledgeable
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    Georgia, USA
    Posts
    40
    It's very useful to run reports with manual filters. I'm amazed that this is the first time you've heard of somebody doing that. Microsoft provides the option to do so, so I assume that it's supposed to work. The thing is, the Open event does not actually run when switching to Print Preview. It just acts like it does. I say this because the Advanced Filter/Sort doesn't show any change from my manual filters. I assume that if the Open event actually ran, the filters would change like they do if I put the automatic filter in the Load event. Is this an incorrect assumption?

    Regardless, I've put the date filter in the button calling the report and avoided the problem altogether. I was just hoping that I could have it work the other way since MS provides the option, and it would have been useful.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    I've worked with posters who wanted to apply manual filter to opened report but this is the first question encountered dealing with printing manually filtered report. I've never needed this in my db designs.

    I did a test of code in report open event, just a Debug.Print, and set a manual filter. The code runs when switching between views and the filter holds. Then I coded to set Filter and FilterOn properties and tried applying manual filter along with the coded filter. When I switch views, the manual filter is dropped and the coded filter applies.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Print & Print Preview Differ
    By IDH in forum Reports
    Replies: 3
    Last Post: 07-25-2012, 09:50 AM
  2. Replies: 1
    Last Post: 01-02-2012, 06:39 PM
  3. Replies: 1
    Last Post: 08-16-2011, 10:24 AM
  4. Print Preview different from Print Hardcopy
    By peterc in forum Reports
    Replies: 4
    Last Post: 10-27-2009, 05:35 AM
  5. Error when trying to print or print preview
    By TriAdX in forum Reports
    Replies: 8
    Last Post: 08-25-2009, 08:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums