Filter Form, Print Report based on Filter

  • Thread starter Thread starter 2Blessed4Stress
  • Start date Start date
2

2Blessed4Stress

I have a report where the user can filter the results on the form using
Access filter keys. I have a button on my form that prints the results of
the filter. My problem is when the user returns to the form the next time,
the report will show up blank. I'm not that good in coding but I was using
this, based on a response on here.

Private Sub cmd_Preview_Click
Dim strWhere As String
If Me. Dirty Then Me. Dirty = False 'save any edits
If Me.FilterOn Then strWhere = Me.Filter
DoCmd.OpenReport "My Report", acViewPreview, , strWhere
End Sub

I don't want the report to remember the filter after it is closed. Should I
be using something else?
 
Try changing the line:

If Me.FilterOn Then strWhere = Me.Filter

to

If Me.FilterOn Then strWhere = Me.Filter Else strWhere = "1=1"


Ray
 
Back
Top