February 7th, 2013, 04:45 PM
My situation - I have a form [frmReport] which has a subform [frmSubReport] which is set to datasheet view. The subform displays select data from all records, I did attempt to use a listbox, but found that the subform setup is easier for sorting & filtering.
My issue is this, I have a print button on the form which when clicked I want to display my report with the all records or if a filter is applied display to filtered records. I'm using to following code:
It does work however when I apply a filter and close the report, the next time I go to run a report say of all the records the previous filter is still there. What am I missing?
Private Sub cmdPrintPreview_Click()
DoCmd.OpenReport "rptRequestSummary", acViewPreview, , Me.frmSubReport.Form.Filter
Sorry if this is basic but I'm pretty new to this and don't know the ins and outs of VBA, I'm still pinching and modifying code off the net.
I'm using 2007 if that makes a difference.
February 9th, 2013, 05:46 PM
In access it's always good practice to destroy what you create. In this case the filter. Try me.frmsubreport.form.filteron = false after you close your report (perhaps in the close event of the report.) You may have to tinker with it to get it to work for application but hopefully this gives you the right idea.
February 10th, 2013, 06:10 PM
I ended up using Forms.frmReports.frmSubReport.Form.Filter = "" on the on close event on the report which so far does the job well.
Ps. Thanks for the tip on destroying what you create, something I never really thought about.