Introduction to calling crystal reports in VB

Source: Internet
Author: User

Environment: VB6.0, crystal reports 9.0
Use crystal reports in a project to summarize some experiences and lessons.
This document is used as an example.
The document includes the document header and document body. The relationship between the document header and the document body may be one-to-many. And they exist in two tables respectively, and are associated with the field FID. The FID parameter must be dynamically passed in to display different results.
First, open crystal reports and make a document template rpt. There are many ways to create a report. For example, you can use its graphical tool to directly establish connections between several tables and then place the fields you want to display in the report; or call a stored procedure that has been written, or directly edit the COMMAND. Then, place the fields to be displayed in the report. However, this is often the case. For reports made using graphical tools, some data cannot be displayed because the fields do not match when the report is input to DATASOURCE in VB. Therefore, we recommend that you use COMMAND in crystal reports to edit SQL statements and create documents. Copy the SQL statement to the VB code, generate a new result set, and assign it to the new data source of the rpt file. To ensure the corresponding fields.
Assume that the document header information is stored in the table Quotation, and the document body is stored in the table QuotationEntry. The customer name FCustomer, Document No. FBillNo, and document date FBillDate must be displayed in the document header information, produced by FBiller ......; the document body must display the product details, including the product code FNumber, Product Style FStyle, product size FSize, product color FColor ...... the FID of the two table join fields.
Therefore, add the SQL statement "select a. *, B. * from Quotation a left join QuotationEntry B on a. FID = B. FID" to the command in the rpt file ". Then, add the required fields to the report.
In VB, first apply crystal reports 9 actionX designer disign and runtime library, and add the part crystal report viewer control 9.
Add the added part in FORM. You can call and display it.
Public BillID as integer
Private Sub commandementclick ()
Dim capp As New CRAXDDRT. Application

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.