Left Quote    Knowledge speaks, but wisdom listens.
- Jimi Hendrix    
Right Quote
[login] | [Register]

Using Crystal Reports in VB

by: bs0d
Page: 1 of 3
(View All)


The crystal report writer is an add-in program that comes with visual basic. You use the Crystal Report Writer to create custom reports, lists, labels and form letters using datga from an existing database. However, most of the time- the Crystal Report Writer is used to create reports.

The crystal report writer can be used with the following programs:

  • Microsoft Access
  • dBase
  • Paradox
  • FoxPro
  • Clipper
  • Btrieve
  • SQL Server (via ODBC)

To access the crystal report writer (in visual basic 6.0) click on Add-Ins --> Report Designer. This will take you into Crystal Reports.


To create a report, open crystal report writer...

  1. click on File --> New (a Create New dialog will appear).
  2. click on the Standard icon (the Create Report Expert dialog box appears).
  3. click on Datafile (the Choose Database File dialog box appears).

To the left you will see a list of files. To the right is the path showing the folder tree, indicating where the file will be stored.

  1. Click on the file you want to open
  2. Click on Add
  3. Click on Done (the Choose Database File dialog box disappears).


Click on 2: FIELD in the create report expert dialog box. This is where you select the fields that you want to appear in your report. You can select the fields individually by clicking on them and then clicking on ADD, or you can click on ALL, which will select all fields. When a field has been selected, it will be displayed in the REPORT FIELDS window.

You can change column headings as well by clicking and highlighting a field in the Report Fields window, and moving down and typing a new heading for that field. Default headings will appear for each field.


Click on 3: SORT tab in the Create Report Expert dialog box. Now select the field you want to have the records sorted by (the selected field will be used to sort all of the records in order by the field selected when the report is produced). You can also set the order to have the table sort in descending order by clicking on the array. Ascending order is the default.


Your report has the ability to calculate totals for numeric fields. You can add additional fields by clicking the field and then click the add button. And to delete fields, click on the remove button.

Click on 4: TOTAL tab in the Create Report Expert dialog box. Select field by clicking on it to highlight it. This will create subtotals for that field, and will create section breaks in your report for each record and display a total for the selected field. Now click on the Add button, and this will add the field on the right hand side.

Note: if the check box in the lower right-hand corner is checked, you will get grand totals for your report.


If you would like to adjust the font and font size of your report, first select the field you want to change by clicking on it. And if you want to change more than one, hold the CONTROL key and select the fields you want to change. Now click the arrow to the right of the font window, a drop down menu will appear. Select the font you want by clicking on it to highlight it. And click the arrow to the right of the font size, a drop down menu will appear- and select the font size you want by highlighting it.


This section is used often if you have large files and want conditions set on the key field or other fields in the file where only certain records will be selected for printing. Setting some keys in this section will speed up processing of records for your report since several records will be skipped.

Click on 5: SELECT tab in the Create Report Expert dialog box. Next, click on SPEED TIP button. This will discuss how records will be selected and how reports will be sped up, if not all records will be used for processing. Now click on OK when finnished reading. Click ADD to add the highlighted field to the Select Fields list box.

The highlight button appears next to the key field in the Report Fields list box. This is because the table contains an index for this field. The key field is often used for filtering out records.

At the bottom of the window, there are two other list boxes, one containing the word "is" and the other containing the words "any value". These two list boxes are used to set conditions to filter out records when producing your report.


Click on 6: STYLE tab in the Create Report Expert dialog box. On the left will be a list of styles that you can choose your report to appear in. Click on the one you want. Enter a title for your report by typing it in where it says TITLE at the tob of the Select Fields List Box.


To preview the 'final product' simply click PREVIEW REPORT. This will take you to your preview screen showing teh actual report that you have created. There are two modes you can look at in preview report, DESIGN mode and PREVIEW mode.


The design section shows the layout of each field in the report, along with titles, headings and totals. You can change the position of a field, making it longer or shorter by clicking on it. You can also change the font and font size of that field.
The design tab contains six sections, as described below...

  1. Title -- Contains information you want to display on the first page only.
  2. Page Header -- Specifies information such as the report title, field headings, and the date.
  3. Details -- Contains the body of the report, database records and subtotals (if you include them).
  4. Grand Total -- Shows the grand totals of all numeric fields talked about in "Totals and Subtotals" above. This section will only appear if you included a grand total in your report.
  5. Page Footer -- Contains page number and any other information you want to appear at the bottom of the page.
  6. Summary -- Contains information you want to appear on the last page only.


Just like with anything else, just play around a bit with the crystal report writer. There is really nothing much complicated with it. By reading this tutorial, you should be more familiar with what each part of the crystal report writer does, and be able to work around a bit easier.

1  |  2  |  3  |  
Next »

No Comments for this page.

You Must be logged in or a member to comment.

Tutorial Stats

Tutorial Stats

0 Total Comments
0 Rating of 5 ( Votes)


Tutorial Options

· Login to Rate This Article
· Login to Post a Comment
· Read more by this author
Digg This Article! Bookmark This Article Reddit: Bookmark This Article BlinkList: Blink This Article! YahooMyWeb BlogMarks: Add This Mark! Furl: Save This Article Spurl: Mark This Article



· Getting Started with VB 6.0
· Coding a Webserver
Your Article Here

"" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank