Populating sub report based on parent report value (1 Viewer)

arichins

Registered User.
Local time
Yesterday, 21:53
Joined
Apr 9, 2009
Messages
95
I made a form, where a user can select the value of 3 fields from a combo boxes. The values of these fields are passed to a report as parameters. The report parses out the parameters and uses them in the record source query.

So far so good. My problem is, the report has a sub report, which needs to populate based on values that were passed to this parent report.

So on the report_load event of the sub report, I set variables equal to the value of the fields on the parent report, redefine the record source, and do a Me.requery. But access throws an error on the requery. "the expression you entered refers to an object that is closed or doesn't exist"

I've verified that the values are actually being passed to the sub report load routine. And the subform will populate with data if I just explicitly set the recordsource.
 

Ranman256

Well-known member
Local time
Today, 00:53
Joined
Apr 9, 2015
Messages
4,337
theres no need to redefine the recordsource of the subreport.

IF ALL 3 cbos are ALWAYS FILLed for every report, then the sub report doesnt change.
it always has 3 linking indexs to the parent.

IF the 3 cbo boxs are not all set at once, then the subreport must change in the Report_Load event depending on which X/3 boxes are set.
BUT the subrpt data does not. The subrpt data will always be 'all data',
then the linking fields will filter out the data.
 

arichins

Registered User.
Local time
Yesterday, 21:53
Joined
Apr 9, 2009
Messages
95
theres no need to redefine the recordsource of the subreport.

IF ALL 3 cbos are ALWAYS FILLed for every report, then the sub report doesnt change.
it always has 3 linking indexs to the parent.

IF the 3 cbo boxs are not all set at once, then the subreport must change in the Report_Load event depending on which X/3 boxes are set.
BUT the subrpt data does not. The subrpt data will always be 'all data',
then the linking fields will filter out the data.

Right, I can set the record source of the sub form to look at the value of the drop down fields, and it'll work fine, for one route.

What I'm trying to do, is allow someone to select a route, and have a report that shows data pertaining to the route, and the sub form has stop data for all that route (and each route has multiple stops).

So I don't see how this strategy will work if I want the report to generate for multiple routes. Example: page 1 is route 101 sub report route 101s stops, page 2 is route 102 and sub report is route 102s stops.....

I'm thinking that the sub report is going to need to draw the parameter from the parent report, for this to work. If I tell the sub report to get stops for multiple routes, I"m just going get route 101 with the stops for several routes in the sub report.

I just can't figure out how to get the sub report to "requery" after I change its recordsource.
 
Last edited:

arichins

Registered User.
Local time
Yesterday, 21:53
Joined
Apr 9, 2009
Messages
95
I figured out what my problem was, I had to put the requery statement in the report open event. I had it in form load.
 

Users who are viewing this thread

Top Bottom