filtering a sub report

  • Thread starter Thread starter Anja
  • Start date Start date
A

Anja

Hello everyone,

I have a main report and a sub report embedded in the main report.
Now, my main report is filtered by a date range and I want to pass the
same date range as a filter to the sub report. What is the easiest way
to do this in Access?

Can I access the sub report and set the filter before I call
OpenReport on the main report?

Appreciate any help you can give me.

Anja
 
Hi,
try to use either format event of section, where subreport placed, or use
report's open event to set subreport recordsource


Hello,

Thanks for your reply. Could you show me how I can set the
recordsource to a query through VBA?

So, I have a query and I need to pass a WHERE clause to this query and
set this query as the recordsource of the subreport...

Sorry if this is a very newbie question but I am not very good with MS
stuff and the reporting module of Access is quite confusing!

Thanks,
Anja
 
Hi,
say you have subreport rptOrderDetails placed on a main report, and
subreport control has the same name, then code will look like:

strWhere = "OrderID= 4" 'var to hold filter string

me.rptOrderDetails.Report.RecordSource = "Select * from OrderDetails Where "
& strWhere


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 
Back
Top