Master detail report is a report that consists of two parts: main report and sub report. The common use of master detail report is to display category by items. When you want to see the category and its products, the master detail report is the important thing you should use. The way to create master detail report is similar to the way you create master detail form when you Subform/Subreport control. You can create a master detail report in three ways as the following:
For example, you have a master detail report as the figure below:
To create the master detail report above, firstly, you need to have a main report by constructing it by using Report Design. Then you have to drag Subform/Subreport on the main report as the figure:
When you drag and drop the Subform/Subreport control on the main report, the SubReport Wizard dialog box appears. Now, Access starts the subreport wizard and you must follow the following steps:
- Click Next
Access displays the second SubReport Wizard dialog box.
This dialog box allows you to select the fields you want to show on your subreport.
- Click drop-down arrow of combo box
- Click the table's name of the subreport (TblProduct)
- Click or or double-click the fields you to display on the subreport
- Click Next
Access displays the third SubReport Wizard dialog box.
This dialog box allows you to define which fields link your main report by choosing from a list or defining your own. If you want to define fields from the list, click Choosing define a list option button. Otherwise, click Define my own option button if you want to define fields by yourself. Suppose, you select Choose from a list.
- Click Next
Access displays the last SubReport Wizard dialog box.
This dialog box allows you to set the subreport's title.
- Click Finish
- Click View
You get the master detail report as the figure below:
Your master detail report may look not nice like the master detail report example above, don't wary, open the report in Design View and make the design changes to the report as you like
This is the second way of creating a master detail report. By using this way, you may spend less time than using Subform/Subreport control. We use the master detail report example above to express you. To create the master detail report, do the following:
- Create a main form in Design View
- Drag and drop TblProduct on the main report as the figure below:
Access starts the subreport wizard, so you can follow the steps of subreport wizard that already demonstrated in Creating master detail report by using Subfrom/Subreport control section.
Note: By creating master detail by using Subform/Subreport control and by using table, you also can create the main report by using Report Wizard, but you need to open it in Design View before you place Subform/Subreport on it. When you drag Subform/Subreport control on the main report make sure it is selected with Wizard.
It is the last way of creating a master detail report. By using this way, you need to create a main report by using Report Wizard as the figure:
Then you need to create a subreport by using Report, Blank Report, Report Wizard or Report Design as the figure:
Next, you need to drag and drop the subreport on the main report as the figure:
In this view, you can make advanced design changes to the report such as changing the report's title, font name, color, back ground, resizing text boxes, etc.
Lastly, click View to see the result.
Note: The main report and subreport must have a linking field. If not, Access cannot create a useful master detail report. See the master detail report example above, the main report have a linked field with the subreport through CategoryID.
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: