Data Dynamics Reports Online Help
Walkthrough: Master Reports
See Also Support Forum
User Guide > Samples and Walkthroughs > Walkthroughs > Walkthrough: Master Reports

Glossary Item Box

You can create a master report using Data Dynamics Reports that can be reused with many content reports. Information in the master report can be modified and the changes will automatically appear in any reports that reference it.

This walkthrough illustrates how to create a simple letterhead master report and a customer letter content report.

The walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the Reels sample database included with this installation.

When you are finished you will have a report that looks similar to the following.

Creating a Master Report

To create a master report in Visual Studio

  1. Create a new project in Visual Studio.
  2. From the Visual Studio Project menu, select Add New Item.
  3. In the Categories pane, select Data Dynamics Reports.
  4. In the Templates pane, select Master Report and name the report Letterhead.rdlx-master.
  5. Click Add in Visual Studio 2005. 

Connecting the report to a data source

To connect the report to a data source

  1. If the Data Explorer is not in view, from the View menu, select Other Windows, then Data Dynamics Reports Data Explorer (at the bottom).
  2. Click the Add icon and select the Data Source... option.
  3. In the Report DataSource smart panel that appears, select the General page.
  4. Change the Name to Reels.
  5. Select the Shared Reference checkbox.

     

  6. Click the Browse button and select ReelsDataSource.rdsx, which is located in C:\My Documents\Data Dynamics\Reports\build number\Samples\Reels.
    Note: In Windows Vista, the path is C:\User\your name\Documents\Data Dynamics\Reports\build number\Samples\Reels\.
  7. Click the Accept button in the lower right corner to close the smart panel and see Reels appear in the Data Explorer.

Adding a dataset

To add a dataset

  1. Click the Add icon and select the Data Set... option.
  2. In the DataSet smart panel that appears, select the General page.
  3. Change the Name to Addresses.
  4. On the Query page, paste the following SQL command into the Query text box:
     

    SELECT FirstName & " " & LastName AS Name, Address1, Address2, City & ", " & Region & " " & PostalCode AS CityStateZip FROM CustomerMailingList WHERE Country = "USA" AND Region = "WA";

  5. Click the Validate icon to validate the query and to populate the Fields list.
  6. Click the Accept button in the lower right corner to close the smart panel and see Addresses and the selected fields appear in the Data Explorer.

Adding controls to contain data

To add controls to the master report

  1. To add a page header to the report:
    • In Layout view, click in or below the report body to ensure that the report has focus.
    • Open the Report menu and select Page Header.
    • Select the page header and change the BackgroundColor property to Khaki.
    • Expand the Size property and change the Height to 1in.
  2. Drag four text boxes from the toolbox onto the page header, and set their properties as in the following table.
    Value Location Size Formatting
    Mass Mailers, Inc. 0in, 0in 6.5in, 0.25in FontSize: 16pt, Bold, TextAlign: Center
    4579 Coastal Cows Drive 0in, 0.25in 6.5in, 0.2in TextAlign: Center
    Jenner, California  95450 0in, 0.45in 6.5in, 0.2in TextAlign: Center
    (707) 555-8686 0in, 0.65in 6.5in, 0.2in TextAlign: Center
  3. To add a page footer to the report:
    • Open the Report menu and select Page Footer.
    • Click in the new page footer to select it and change the BackgroundColor property to LightGoldenrodYellow.
  4. Drag two text boxes from the toolbox onto the page footer, and set their properties as in the following table.
    Value Location Size Formatting
    Mass Mailers, Inc. 0in, 0in 6.5in, 0.25in Bold, TextAlign: Center
    "Improving life through the constant exercise of mailbox hinges." 0in, 0.25in 6.5in, 0.25in TextAlign: Center

To add a region which Content Report users can use

  1. Drag a ContentPlaceHolder report item (available only in Master Reports) from the toolbox onto the body of the report and set its properties as in the following table. The Text property allows you to provide instruction for those creating Content Reports based on your Master Report.
    Location Size Text
    0in, 0in 6.5in, 3.25in Drag report items from the toolbox into this area to create your form letter.

To set report properties

  1. From the Report menu, select Report Properties.
  2. In the Report smart panel that appears, go to the Appearance page.
  3. Set the values of the Left, Right, Top, and Bottom margins to 1in.
  4. Click the Accept button in the lower right corner to close the smart panel.
  5. From the File menu, select Save.

Creating a Content Report

To create a content report in Visual Studio

  1. From the Visual Studio Project menu, select Add New Item.
  2. In the Categories pane, select Data Dynamics Reports.
  3. In the Templates pane, select Report Content and name the report LetterContent.rdlx.
  4. Click Add in Visual Studio 2005. 
  5. In the Open dialog that appears, select the Letterhead.rdlx-master that we just created.
  6. Click the Open button.

Adding controls to contain data

Notice that all of the report items added to the master report are disabled in the content report. The only area of the content report to which you can add controls is the ContentPlaceHolder. When you click the Data Explorer icon, you can access data used in the master report, and you can add your own data source and data sets.

To add controls to the content report

  1. From the toolbox, drag a List data region onto the body of the report and in the property grid, set its properties as in the following table. (The list data region will repeat for every row of data in any data fields it contains.)
    DataSetName Location Size
    Addresses 0in, 0in 6.5in, 3in
  2. Right-click the List data region and select Properties to open the List Data Region smart panel.
  3. Select the Detail Grouping page, and set the Group on Expression to:
    =Fields!Name.Value
    Tip: The reason for setting this grouping is so that we can set Page break at end in the next step. If we set the PageBreakAtEnd property on the List itself, it would not break until after all of the data was processed.
  4. Select the Page break at end check box to start each letter on a new page.
  5. Click the Accept button in the lower right corner to close the smart panel.
  6. Drag a TextBox report item onto the list at the Location 5in, 0in, and set the Size to 1.5in, 0.25in
  7. In the property grid, drop down the box next to the Value property and select <Expression...>.
  8. In the Expression Editor under Fields, expand the Globals node and double-click ExecutionTime. This automatically renders the current time and date when the report is executed. Click the OK button to accept the change.
  9. In the property grid, set the Format property for the text box to d for short date formatting.
  10. If the Data Explorer is not in view, from the View menu, select Other Windows, then Data Dynamics Reports Data Explorer (at the bottom).
  11. From Addresses in the Data Explorer, drag the following fields onto the list and set their properties as in the following table.
    Field Location Size Other
    Name 0in, 0in 3.5in, 0.2in
    Address1 0in, 0.2in 3.5in, 0.2in
    Address2 0in, 0.4in 3.5in, 0.2in CanShrink: True
    CityStateZip 0in, 0.6in 3.5in, 0.2in
  12. Drag five text boxes from the toolbox onto the list below the fields, and set their properties as in the following table. (Placing static text boxes on the list ensures that the text is repeated after each row of data in the fields.)
    Value Location Size Formatting
    Dear Madam or Sir, 0in, 1in 1.3in, 0.25in
    Thank you for taking the time to fill out our Movie User Ratings survey. As a token of our appreciation, we are enclosing a gift certificate in the amount of $10 which can be used at any Reels Movie location. You can find a Reels Movie location near you on their Web site at www.reels.com. 0in, 1.375in 6.5in, 0.625in
    Best Regards, 5in, 2.125in 1.5in, 0.25in TextAlign: Right
    Neal Marmoset 5in, 2.75in 1.5in, 0.25in TextAlign: Right
    Survey Administration 5in, 3in 1.5in, 0.25in TextAlign: Right
  13. From the File menu, select Save.

Viewing the report

Any report designed with Data Dynamics Reports can be opened in the included Data Dynamics Reports Viewer application or you can view it at design time.

To view the report at design time

  1. Click the Preview tab of the report designer.
  2. To see page settings such as margins, click the Print Preview icon.

To view the report at run time

  1. Add the ReportPreview control to your Visual Studio toolbox and drop it onto your Windows form.
  2. Set the Dock property of ReportPreview1 to Fill so that it will automatically resize if the form is resized at run time.
  3. Double-click the viewer to go to the Load event and use code like the following.
    'Visual Basic.NET 
    Dim rpt As New System.IO.FileInfo(Application.StartupPath & "..\\..\\LetterContent.rdlx") 
    Me.ReportPreview1.OpenReport(rpt)
    //C# 
    System.IO.FileInfo rpt = new System.IO.FileInfo(Application.StartupPath + @"..\..\..\LetterContent.rdlx"); 
    this.reportPreview1.OpenReport(rpt);
  4. Run the project.

See Also

©2010. GrapeCity, inc. All Rights Reserved.