Typical method of printing Crystal Report by VB 1

Source: Internet
Author: User
Tags odbc connection reset
Program | print | Crystal Report
Describe:



This paper introduces a popular method of printing Crystal Report by VB Program, which has a good expansibility.



Environment:

MS SQL SERVER 2000/vb6/crystal REPORT8.5



Steps



1: Establish an ODBC connection



2: Create a process for retrieving data for the Crystal (procedure)

Example: (Total by date query)

if exists (select * from sysobjects where name = ' Usp_testfjs ')

drop proc Usp_testfjs

Go

Create proc Usp_testfjs

@strDate varchar (20)

As

Select SUM (tot_amt) as Total_amount

From Trans_header

where convert (varchar, bus_dt,120) = @strDate

Go



3. Create a Crystal report using procedure

Steps are the same as creating a generic report, but note that when selecting a data source, stored procedures on the options



4. Create VB Program

Note Add a Crystal Report control (Crystal)

One of the simplest programs:

For example:

Private Sub Command1_Click ()

Dim IRet as Integer

Crystalreport1.reset/*reset data*/

Crystalreport1.reportfilename = App.Path + "\totalamount.rpt"

/*link the Crystal with actual rpt file */

Crystalreport1.storedprocparam (0) = Format (trim$ (Dtpicker1.value), "Yyyy-mm-dd")

/*assign the parameter*/

Crystalreport1.windowstate = crptmaximized

Crystalreport1.windowtitle = "HELLO"

IRet = Crystalreport1.printreport

/*retrieve the Data and display the printpreview screen * *



Summarize:

This method realizes the Crystal Report and the VB program independence, the user to the report format change will be limited to the Crystal Report modification scope. It is recommended that you adopt this approach.






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.