Using Crystal Reports'Crystal Reports' is a popular third party package that is included with Visual Basic, which allows you to create reports for your application. The package consists of a designer - where you can design and test the reports, Crystal Reports API calls and Crystal Reports control. Note: Crystal Reports is shipped and installed as part of the VB installation package except in VB6. This can be found in \common\tools\crysrep double click on crystl32.exe to install. Creating a ReportVB5 or less VB6 Lets have a quick look at the Designer
Initially there is one tab on the report - Design - when you select the print preview to see how the report looks with data in, another tab named Preview will appear. While you are in design mode you can draw and arrange the data fields on the report. This is done in a similar way to creating controls on a form in VB. For the purposes of this tutorial we will be creating a simple report from the sample database BIBLIO.
Now we are ready to draw the report
Drag and drop the fields you want on to the report. So that it looks like the report above. Now if you run it by selecting Print Preview, you can see what the report looks like. Now save the report and we have a template that now can be used in VB. Note: Turn off the Save Data with report option if you want the data to contain new information each time the report is used. Going to the File menu, selecting Options and clicking on the Reporting Tab sets the option This is fine I hear you say, but what if I don't want all the data. There are many options in the Crystal Reports and as this tutorial is more of an overview I will not be going into it. But one important thing to do is to get specific data. This is done by a selection formula (i.e. the Where clause of a SQL statement).
The above formula will only show Authors that have had their book published in 1984. Using Crystal Reports in VBWhen you have designed your report, the saved file should have an extension .rpt. You can use this report with the Crystal Report control to display or print your report in a VB application. Note:Check the crystal report help files for the files you need to distribute with the control. You will also need any .rpt files that you have created You will have to add the Crystal Report control to the toolbox, this is done by going to the Project menu and selecting Components, then looking down the list for the control and clicking on it To use the control add it to a form and set the following properties
To display the report use the .printreport method i.e CrystalReport1.PrintReport There is alot more to crystal reports than I have covered here, but I hope it gives you an idea of how Crystal Reports works. I have not used the new features in Version 8, but it should still work.
|
Quick searches: Site Search | Advanced Site Search |
|
By using this site you agree to its terms and conditions VB Explorer and VBExplorer.com are trademarks of Exhedra Solutions, Inc. |