Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Access Crystel report from VB program.

Status
Not open for further replies.

pammi

Programmer
May 14, 2002
14
0
0
SG
Hi,
I have started leanring Crystal reports just few days before and wondering how I can access crystal report from my VB program.
Anyone pls help me. Thanks
Pammi
 
Hi Pammi

Have you purchased Crystal Reports separately, or are you using version 4.6 that is supplied with VB6 Ent. Ed.? The version supplied with VB (although well hidden on the 3rd CD and not installed by default), does integrate itself with the IDE so that the Report Designer option appears on the Add-Ins menu.

As regards running a report from VB, in the VB6 IDE, if you right-click on the toolbox, click on Components, scroll down until you see the Crystal Report Control, click to put a tick in the box beside it and click OK. You should get the control added to your toolbox. You can then click on the control and draw it on your form. Once that's done you can set the properties of the control to tell it which report to run etc. The control is invisible at run time.

If you need any further info, please let me know.

Best regards

Billy Crosbie
WexSoft Software Consultants
 
If you have the current version of CR (8.5) you have to have the developers edition to integrate with VB. You would also have received the developers help which gives the basics.

The CD website describes many of the basics and has sample apps. There are 4 different sets of syntax, so you have to decide which you are going to use before you can learn the coding. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Wexsoft,
I am using Crystal Reports 7.0 and I know that I have to use Crystal Report Control but How that I don't know? Can u help me further that what preperties I need to set to view the report.
Pammi
 
Hi Pammi

Sorry for the delay in getting back to you.

Assuming you have the Crystal Report Control available (as per instructions in last reply), create a new standard EXE project, put a report control and a command button on the form. Let's assume the report is called CR1.RPT and that it's in the same directory as the project you created (if it's in a different directory, include the full path file name in the ReportFileName property).

The click event for the command button should be set as follows:

Private Sub Command1_Click()

With Form1.CrystalReport1
.ReportFileName = "CR1.rpt"
.ReportTitle = "Crystal 1"
.PrinterCopies = 1
.PrinterCollation = crptDefault
.WindowControls = True
.WindowBorderStyle = crptSizable
.WindowControlBox = True
.WindowState = crptNormal
.WindowTitle = "Previewing Crystal 1"
.Destination = crptToWindow
.PrintReport
End With
End Sub

The only property you really need is ReportFileName and the PrintReport method should preview the report.

If you need anymore, let me know.

Best regards

Billy Crosbie
WexSoft Software Consultants
 
Hi Wexsoft,

The above works fine.
I need to pass the parameter values from VB to crystal report. Lets say i want to generate the report for a particular date. then How can I pass the parameter? Please Help.....

Pammi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top