A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Filter Form, Print Report based on Filter



 
 
Thread Tools Display Modes
  #1  
Old July 2nd, 2009, 05:36 PM posted to microsoft.public.access.forms
2Blessed4Stress
external usenet poster
 
Posts: 30
Default Filter Form, Print Report based on Filter

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?
  #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?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.