description:
This article describes another popular VB program to print crystal reports.
Environment: MS SQL Server 2000 / VB6 / Crystal Report8.5
step
1: Establish an ODBC connection
2: Create a file for Crystal Report
3: Load Microsoft ActiveX Data Objects Library to the project's References
4. Create a VB Designer, load the Crystal Report report file in the way Open existing file.
If the report conditions need to write some simple programs from the screen input,
Dim Adors as adod.recordset
Private sub report_initialize ()
SQL $ = "SELECT * from view_xxxx we xxxx"
'According to the picture, re-get WHERE Condition'
SET Adors = CreateObject ("AdoDb.Recordset")
Adors.open SQL $, "Provider = msdasql.1; Persist Security Info = False; Data Source = ODBC_SALES", AdopenKeyset, AdlockBatchOptimistic
Database.setDataSource Adors
End Sub
Private sub report_terminate ()
Set adorse = nothing
End Sub
5: Create a VB screen (FORM), join the Crystal Report Viewer control
Some simple programs, examples
DIM RPTREPORTNAME AS RPT_REPORTNAME 'RPTREPORTNAME IS NAME OF Designer
Private sub flow_load ()
CRVIEWER1.Reportsource = RPTREPORTNAME
CRVIEWER1.VIEWREPORT
End Sub
to sum up:
This method implements the control of the VB program to the crystal report, but is not as effective as the former scalability, the format of any report is changed, and the entire project is required.