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 integrate Crystal Reports 8.5 (RDC)

COM and Automation

How to integrate Crystal Reports 8.5 (RDC)

by  hoosier121  Posted    (Edited  )
The following is a strategy for integrating Crystal Reports 8.5 (using the Report Designer Component (RDC)) with FoxPro 7.0. The concept is to create a ôReport Viewingö form that is called from a menu or a button on another form. I use one æReport ViewerÆ form and pass the report name and other parameters from the preceding form. I will cover topics like the following: preview the report, pass parameters to the report, and manipulating the viewer when it initiates on the form.

This following code is a combination of Craig BernstonÆs and the Crystal Reports Documentation.

ò Create a form
ò Add the Crystal Viewer OLE control to the form
ò Place the following code in their mentioned methods

PROCEDURE Error
LPARAMETERS nError, cMethod, nLine

IF nError != 1440
* Error 1440 is caused by the Crystal Report Viewer
* when you try to display it before the report is done
* loading. We'll ignore it and trap all other errors.
DODEFAULT()
ENDIF
ENDPROC

PROCEDURE Init
PARAMETERS cReportName, nClientId

*** Assign the ReportName
This.Reportname = cReportName

LOCAL crapplication, crreport

*** Create the Report using RDC
crapplication = CREATEOBJECT("CrystalRuntime.Application")
crreport = ("CrystalRuntime.Report")
crreport = crapplication.OpenReport(cReportName)
ThisForm.olecontrol1.ReportSource = crreport

IF cReportName = "Reports\MASTER-REPORT.rpt"
*** Assign the ClientId
This.currentclient = nClientId
*** Pass Parameters
crreport.parameterfields.item(1).SetCurrentValue (nClientId)
ENDIF

*** Preview the Report
ThisForm.oleControl1.ViewReport

*** Sets the Properties of the Report Viewer
WITH This.olecontrol1
.Top = 5
.Left = 5
.Height = ThisForm.Height - 2
.Width = ThisForm.Width - 2
ENDWITH

This.olecontrol1.EnableExportButton = .T.
This.olecontrol1.EnableGroupTree = .F.
This.olecontrol1.EnableRefreshButton = .F.
This.olecontrol1.Zoom(1)
ENDPROC

PROCEDURE Load
*** ReportViewerForm.Load
*** Enables ActiveX dual interface support
SYS(2333,1)
ENDPROC

PROCEDURE Resize
*** Resize the report viewer to the form
WITH This
.olecontrol1.Top = 1
.olecontrol1.Left = 1
.olecontrol1.Height = .Height - 2
.olecontrol1.Width = .Width - 2
ENDWITH
ENDPROC
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top