[Migrated content. Thread originally posted on 21 March 2003]
I'm trying to use the Crystal Reports Viewer control version 8.5 and I can't seem to get it to display a report. Has anyone been able to get this control to work?I get the control to display, but when I try to modify the control to display a report, I get a Type mismatch error.
The CRView.def file has the following definition:
* CRViewer
CLASS @CRViewer
CLSID, C4847596-972C-11D0-9567-00A0C9273C2A
NAME, "CRViewer"
PRIMARY-INTERFACE
ACTIVE-X-CONTROL
DEFAULT-INTERFACE, "ICrystalReportViewer4"
DEFAULT-SOURCE, "_ICRViewerEvents"
* ReportSource
* Get the report source
PROPERTY-GET, 250, @ReportSource
RETURNING "IUnknown*", TYPE 13
* ReportSource
* Get the report source
PROPERTY-PUT, 250, @ReportSource,
"IUnknown* (Property Value)", TYPE 13
Snippets of my code are:
...
WORKING-STORAGE SECTION.
77 WS-FILE PIC X(256) VALUE SPACES.
...
SCREEN SECTION.
01 CRV-SCREEN.
03 CR-VIEWER, CRViewer,
COL 1 PIXELS, LINE 1 PIXELS, LINES 365 PIXELS,
SIZE 535 PIXELS,
ID IS 1, INITIAL-STATE (ActiveX-Res, "Res-Tag-1"),
EVENT PROCEDURE CR-VIEWER-HANDLER.
PROCEDURE DIVISION.
....
DISPLAY Standard WINDOW LINES 36.50 SIZE 53.50 CELL
HEIGHT 10 CELL WIDTH 10
AUTO-MINIMIZE COLOR IS 65793 CONTROL FONT Small-Font
CONTROLS-UNCROPPED
LABEL-OFFSET 0 NO SCROLL WITH SYSTEM MENU
TITLE "Crystal Report Viewer 8.5 Test" TITLE-BAR
NO WRAP HANDLE IS VIEWER-WINDOW.
DISPLAY CRV-SCREEN.
MOVE "C:\\TEST.RPT" TO WS-FILE.
MODIFY CR-VIEWER @ReportSource = WS-FILE.
I guess I'm getting the Type mismatch error because WS-FILE is a PIC X(256) field and the "IUnknown* (Property Value)", TYPE 13 must be expecting a different type of variable. I started thinking that IUnknown* was meaning that it was expecting a pointer variable. So, I set up a pointer variable that I assigned to the address of the WS-FILE variable and then I modified the viewer with the reportsource assigned to the pointer variable. Then, I didn't get the Type mismatch error anymore, instead, it gave me a memory access violation.
Any ideas on how I should define a variable in my program for the "IUnknown* (Property Value)" data item?
Thanks