Tutorial 9-1. Building the Customer Sales Report
Before we practice using subreports, let’s first build the main report. This is going to be the foundation for all the tutorials throughout this chapter. It is a sales report which shows the detail sales record for each customer. This report will serve as the basis for the rest of the tutorials in this chapter.
- First, create a new report using the Standard Report Wizard and select the Xtreme.mdb database.
- Select the tables Customer and Orders. Click the Next button twice to get to the Fields tab.
- Select the following fields from the Customer table: Customer ID, Customer Name.
- Select the following fields from the Orders table: Order Num, Order Date, Ship Date, Order Amount. Click the Next button.
- For the groups, select the field Customers.Customer ID. Click the Next button.
- For the Summaries tab, there will be three summaries already selected (Crystal Reports automatically summarizes all numeric fields), but we only want one of them. Keep the Order Amount summary and delete the summaries for Customer ID and Order ID.
- Click the Next button four times to skip forward to the template tab. Select the template Block (Blue).
- Click the Finish button to save your changes and preview the report. It should look similar to the following:
- This report is a good first attempt, but let’s clean it up a bit before we move on to adding the subreport. Click on the Design tab to start making changes.
- Click on the Business Objects logo in the top right corner and delete it.
- Double-click on the Report Description textbox. Replace the text with “Customer Sales Report”.
- In the Details section, click on the Customer ID field and delete it. It’s already displayed in the group header so we don’t need to repeat it on every row.
- We don’t want the customer name repeated on every row either, so we’ll put it in the group header. Enlarge Group Header #1b and move the Customer Name field from the Details section into the group header.
- Format the Order ID so that it doesn’t have commas in it. Right-click on it and select Format Field. On the Number tab, set the Style to be -1123.
- For both of the date fields, right-click on them and select Format Field. On the Number tab, set the date format to ‘03/01/1999′.
- Save the report as Customer Sales.rpt and preview it. It should look similar to the following: