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.