INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

COM and Automation

How to integrate Crystal Reports 8.5 (RDC) by hoosier121
Posted: 17 Jan 03

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

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close