filtering a sub report

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
 
A

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
 
A

Alex Dybenko

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top