Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subreport is not filtering correctly on final report

Status
Not open for further replies.

wz

Programmer
Feb 16, 2001
88
US
I have a subreport on a report. The end user clicks on a cmd button on a form to open the report. The report is based on a query with a date criteria that is on the form. I am also using a function to filter data on 2 separate option button groups.

My code is simple: domcd.openreport "rptname", acviewpreview, , GetParameters()

My code for GetParameters is more complex but the end result is correct for both the report & subreport if opened independly. In other words the report is filtered correctly and so is the subreport - but when the subreport is on the report it is not filtered correctly.

I have the used the docmd.openreport to see my subreport & it is correct and then my report opens & the subreport is not filtered. ? I tried to save the subreport & it saves with out the filter.....

The end user is tring to print a report that shows:
data with a date, product shift, & product line filter. Each of these with the availabilty of selecting all if wanted. example: data for 9/1/09 for shift 1 on product line 4 or data for 9/1/09 for all shifts on product line 3 or data for 9/1/09 for shift 1 on all product lines, etc.

So I guess 2 questions why is my subreport not keeping the filter when saved? and Is there a way to filter using option buttons with one of the options being all & the filter then does not filter like using the (*)?
 
After trying everything :) ....I got this to work:
docmd.runcommand accmdsave & now my subreport is perfect!

note: the docmd.save did not clear this up
 
The Where Condition of DoCmd.OpenReport will only act against the record source of the main report. If you want to use the same or a similar filter for the subreport, you must apply the filter expression to the subreport's record source separately. I will either modify the record source with criteria like:
Code:
   BETWEEN Forms!frmDates!txtStartDate And Forms!frmDates!txtEndDate

Other times, I will use a little code to change the SQL property of a saved query that feeds the subreport.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top