Skip to main content

[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

[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
The ReportSource property of the CRViewer object is expecting an object, not a filename.
What you should do is add these lines before yours:

CREATE Application OF Report HANDLE IN hReport.
MODIFY hReport OpenReport("c:\\test.rpt") GIVING hReport.

Then change this line of yours:

MODIFY CR-VIEWER @ReportSource = WS-FILE.

To:

MODIFY CR-VIEWER @ReportSource = hReport.

hReport is defined as:

77 hReport USAGE HANDLE OF Report.

[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
Thanks, that worked.
I also had to add a line of code after opening the report which modified the report to force records to be read.

Modify hReport @ReadRecords()

And after modifying the ReportSource, I also had to force the CR-VIEWER to view the report with the following line of code

Modify CR-VIEWER @ViewReport()

[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
Good work, I didn't know you had to do an explicit refresh with ReadRecords, it makes sense though.

I thought this to be a good example to illustrate something that is easily forgotten albeit important.

To all of you working with COM, DCOM and ActiveX. Remember these are separate entities from other software companies, of which at best some of them follow some sort of standard.

Most don't, not necessarily because they don't want to, but because various applications covers various tasks and as such are likely to have various requirements for startup, initialization etc.

What I want to emphasize here, is that we at Acucorp can, and certainly will, tell you how to use ACUCOBOL-GT syntax to ACCESS these technologies, but remember that we in most cases do not have a clue of how to USE the software in question. Nor is it our mission to know.

Sometimes, we happen to know, like me in this case, but it would be the exception rather than the rule. There are so much add-on software out there and so many vendors we cannot possibly get to know them all.

Which explains why a forum like this is so important, as it is a meeting place for all of us to come together and learn how to use various software with standard technology.

Think of it this way: You can buy a car, and you are familiar with the technology, but to use it you have to practise and study driving rules. Take your car to England, and you have to practise again because of different rules (like driving on the "right" side of the road...) The car shop gives you ACCESS to your car, but to USE it, you have to attend driving school.