Subreports 2.1

In the previous article we determined that we needed to use a subreport to add phone numbers and email addresses to our report.

Open the report on the Design tab and delete the phone number field we just added in the Details section. Also add the Constituent ID field (that we added to the export in the previous article) and place it in the Group Header #1 section to the right of the Constituent Name group header field.

Open the Insert menu on the top toolbar and select Subreport.

Select “Create a subreport with the Report Wizard” and enter a name for the subreport. Click the Report Wizard button.

Expanding the Current Connections folder will show the MDB file that the main report is linked to. Select the file path and click the double arrow button to move the MDB file and table names to the right side into the Selected Tables window. Click the Next button and change the table links to Left Outer Join.

Click the Next button to get to the Fields window. If you recall I mentioned that this will be a linked subreport. In order to link the subreport to the main report we need to insert a field to link them with. For this example we will use the Constituent ID (which is why we already added it to the main report a few paragraphs ago).

In the Available Fields window on the left side, expand the GfCnBio and GfCnPh_1 sections.

Double-click the GfCnBio_ID (Constituent ID) and GfCnPh_1_Phone_number fields to move them to the Fields to Display window on the right side. Click the Finish button to get back to the Insert Subreport window. Click on the Link tab so we can link the main report (a.k.a. Container Report) to the subreport.

Double-click the GfCnBio.GfCnBio_ID (Constituent ID) field to move it from the Available Fields window to the Field(s) to link to window on the right. Once you do that the bottom portion of the window will populate and will default to the same field on the subreport. Clicking OK will bring you back to the main report with the subreport box attached to your mouse cursor. Click to place the subreport in the Group Header #1 section to the right of the Constituent ID field.

If you refresh and preview the report now it will probably be a big mess with duplicate phone numbers and emails. There are still some changes we need to make to the subreport that will be covered in the next article.