VB中水晶报表使用(国外英文资料).doc
文本预览下载声明
VB中水晶报表使用(国外英文资料)
The first step:
In the VB Project, the Project menu adds Add Crystal Report 9 and the Report name is used by default. Then Form2 (the Form that Crystal Rerport automatically adds, assuming it is called Form2) is automatically assigned the following code:
Option Explicit
Dim Report as New Cystal1
Private Sub Form_Load ()
Screen. MousePointer = vbHourglass calls the crystal report with the mouse in the hourglass
The value of this statement will be modified later in the crviewer90.reportsource = Report
CRViewer91 ViewReport
Screen. MousePointer = vbDefault calls the crystal report to the default shape
End Sub
Private Sub Form_Resize ()
CRViewer91. Top = 0
CRViewer91. Left = 0
CRViewer91. Height = ScaleHeight
CRViewer91. Width = ScaleWidth
End Sub
Step two:
Click the database field in the Crystal Report designer, and select database expert... , then click create new connections, and then point only field definition, to create database definition file, the field name and width is consistent with the original database table. Finally, the corresponding fields are obtained in the database field, placed on the report, and configured as required by the crystal report.
Step 3:
This step is critical, adding a Modual to the project file, defining the global ADODB variable, and implementing the dynamic connection of the database and the crystal reports. The code is as follows:
Public conn As New ADODB. Connection
Public rs As New ADODB. You
Step 4:
For ADO database connection considerations for VB programs, see the print button routines below.
Private Sub Command1_Click ()
Dim connstr As String
If conn. State = adStateOpen Then conn
Connstr = Provider = Microsoft. Jet.oledb.4.0; Data Source = app.path \ prtest.mdb; Persist Security Info = False prtest.mdb is the test Access database for the current directory of the program
Conn. The ConnectionString = connstr
Conn. Open
Conn. CursorLocation = adUseClient
If rs. State = adStateOpen Then rs. Close
Open test, con
显示全部