Generating a Multiple Table Crystal Report using VS 2005 - Choosing Fields to Include in the Report
(Page 4 of 4 )

You may highlight and transfer the fields to the Fields to Display area as shown. Only these fields will be displayed if you do not make further changes at a later date. The choices made can be modified by returning the fields back to the Available Fields area if necessary.

Now click on the Next button. This opens up the next step of the report where you may be required to group your data based on some field.
Defining Groups

In this window you may also browse the data, or find a field by using the Browse Data... and Find Field... buttons. Highlighting the Customers.City in the available fields area, click on the button labeled Browse data.... This opens up a display list of all the cities as shown.

You may also preview the report by clicking on the MainReportPreview tab (at the bottom of Crystal Report1.rpt tab) as shown in the next picture.

You can review the grouped data on the left hand side of this report as shown and toggle the Grouping button to show the report with grouped data or ungrouped data.

In addition to grouping you may print the data (check how many pages will print before you hit this button!), or export the report into several forms by hitting the export button. The displayed report may be zoomed as well.

When you click on the design view of Form1 you will see an embedded CrystalReportViewer control and a CrystalReport11 (MultiTable.CrystalReport1) control in the control tray as shown. What you see in the CrystalReportViewer1 may not be completely meaningful in the design view, nor in the objects in the "Grouping area."

The CrystalReportViewer1 control has a large number of properties which can be changed. In fact there are links which may be activated to carry out the intended modifications as shown in the properties window of this control.

We will not be making any changes to the report viewer. Now click on the Build main menu item and run the form. The result is shown displayed in the next window. You can choose the city and the order date to find the other details as shown for the city "Bergamo" for the order date 12/14/1999. In this page you may also navigate from page to page, or look for a certain page.

If you want to make changes to the formatting of the report, you should go first to the Main Report after clicking on the CrystalReport1.rpt. You can then make changes to the report objects. If you want to make changes to the fields from the report, for example the OrderDate, you can click on the OrderDate in Section3 (Details) and in the corresponding property window turn off the minutes and seconds from the display by choosing the crNoMinute and crNoSecond values for the MinuteType and secondType properties. Also if you take out the city field being shown in every row, you can make the report more readable.
For formatting you can change the appropriate properties as well. Right clicking on an empty area in a section will bring up the context sensitive drop-down menu from which you can choose to carry out a variety of activities as shown.

After manipulating the fields and formatting the report elements, the report was modified as shown in the next picture. The Crystal Report Viewer control has all the necessary elements to create a visually attractive report, although the report shown may not be the most attractive one.

Summary
This tutorial shows you how to create a multi-table report using the Crystal Report objects called Crystal Report and CrystalReportViewer installed with the default installation of Visual Studio 2005. The wizard makes it very easy to create a report. Modifying the report requires knowledge of the earlier versions of Crystal Report software. The various objects needed for creating an attractive report are available either through property windows or context sensitive drop-down menus.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |