Passing a query parameter to a sub-report

It has been a long time since I worked with MS Access and I'm not sure if I am doing this correctly.

I have a report related to querying a single list of usernames. The report group contains the username and has an additional report in detail, which is a chart.

The sub-report / chart is based on a query that accepts a username parameter. Since the auxiliary report is not connected, I need to pass the username parameter from the main event of the event report to the sub-report and, thus, to the base request.

I do not understand how to do this or even if my approach sounds.

(ps I originally posted to Superuser, but I see that many people use this site.)

thanks for the help

+4
source share
1 answer

To take full advantage of the subheadings, they must be bound to the record source (table or query) and use the Link Master Fields and Link Child Fields properties of the Subform / Subreport element to "synchronize" the data of the sub-recorder with the parent record.

Say you have the [Users] table

 userID ------ Gord Tim 

and table [UserTraffic]

 userID trafficDate downloadMB ------ ----------- ---------- Gord 2013-04-26 366 Gord 2013-04-25 442 Tim 2013-04-26 890 Tim 2013-04-25 212 

Your main report [UserReport] is attached to [Users] and contains a control for reports based on the report [UserTraffic_subreport]

subreport1.png

When you use this report in your Subform / Subreport element in your main form ...

mainreport.png

... be sure to set the Link Master Fields and Link Child Fields properties ...

properties.png

... so your report will look like this:

preview.png

Note that in this example, no VBA code is required.

Edit

The same principles apply when adding a chart to a report. The following report displays user traffic by date, so the record source for the main report

 SELECT DISTINCT trafficDate FROM UserTraffic ORDER BY trafficDate; 

The report uses the Chart control instead of the Subform / Subreport ... element.

design.png

... and the properties of the Chart control ...

properties.png

The final report is as follows

preview.png

+10
source

All Articles