View Single Post
  #2  
Old July 2nd, 2009, 10:50 PM posted to microsoft.public.access.forms
ray
external usenet poster
 
Posts: 475
Default Filter Form, Print Report based on Filter

Try changing the line:

If Me.FilterOn Then strWhere = Me.Filter

to

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


Ray

"2Blessed4Stress" wrote:

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?