Customizer - How to Preview Crystal Report

I am able to generate a custom report to printer  via  Button Click using the following code

dim CRApp
dim Rept
dim RptFile

RptFile = "<ReportPath>"

Set CRApp = CreateObject("CrystalRunTime.Application")
Set Rept = CRApp.OpenReport(RptFile)

With Rept
.ParameterFields.GetItemByName("WorkOrderNo").AddCurrentValue Form.Controls("txtWorkOrderNo").text
.ParameterFields.GetItemByName("CompanyID").AddCurrentValue Session.CompanyID
End With

However, I am looking for a method to Preview it on the Screen instead.  

Using Sage 500 2021 with built in Crystal Reports 11.  Unable to get Viewer to Launch.   

  • 0

    Since you're opening the report using Crystal runtime and bypassing the Sage 500 report engine, you probably want to reference the Crystal report viewer.

  • 0 in reply to Contefication

    I saw that article, but I couldn't get CRViewer to load correctly.    

  • 0 in reply to SSI-Gary

    Not sure what that means. The code is VB and it is very basic, so you have to load the class, but also handle the preview window size. You've created a custom report so there are a number of variables at play. Alternatively, you could also add input parameters to the report and launch it from the Desktop, or create a new BI view and link it to the relevant context menu. You could also review the methods and properties of the CrystalActivexReportViewer using VS or the methods exposed in the Sage 500 report engine. The latter generally requires a specific configuration for the report.

  • 0 in reply to SSI-Gary

    Can you give some details on what you mean by "load correctly"? do you get an error or does the preview screen not display?

    If you are getting an error, can you give the message here and the code area that is giving the error and noting the line it shows up on?

    If the preview window is not displaying can you put the code snippet where you are trying to get it to display?

    I haven't used it much in this method but I do work with Crystal and Sage 500 a lot and maybe I can try to set up a similar scenario here and try to duplicate the process and troubleshoot it for you.