Unable to set com-handle property. (5677)

Please help me to fix this error.

hdl2.jpg


error.jpg


this is my code

PROCEDURE viewreport :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DEFINE VARIABLE chApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chReport AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chConnProps AS COM-HANDLE NO-UNDO.

CREATE 'CrystalRuntime.Application' chApplication.
run p_debug ("Create Report").
CREATE 'CrystalRuntime.Report' chReport.

/* Insert full path to the Crystal report */
chReport = chApplication:OpenReport("e:\test\Test.rpt").

/* Set the Connection Info to Connection Properties of the table object */
chConnProps = chReport:Database:Tables(1):ConnectionProperties.

/* Clear the ConnectionProperties collection */
chConnProps:DeleteAll.

/* Add the ODBC DSN */
chConnProps:ADD("DSN", "fov").

/* Add the database level User ID if required */
chConnProps:ADD("sysprogress", "sysprogress").

/* Add the database level password if required */
chConnProps:ADD("fov", "fov").

/* Example of some adjustable parameters */
MESSAGE "VALID-HANDLE (chCtrlFrame) IS: " + UPPER(string(VALID-HANDLE (chCtrlFrame))) VIEW-AS ALERT-BOX.

chCtrlFrame:CrystalActiveXReportViewer:EnableNavigationControls = TRUE. /* Enables the CRViewer's Navigation Controls */

chCtrlFrame:CrystalActiveXReportViewer:EnableExportButton = TRUE. /* Enables the CRViewer's Export button */

chCtrlFrame:CrystalActiveXReportViewer:EnableSearchControl = FALSE. /* Disables the CRViewer's Search control */


/* Set the report source */
chCtrlFrame:CrystalActiveXReportViewer:ReportSource = chReport.

/* View the report */
chCtrlFrame:CrystalActiveXReportViewer:ViewReport().


run p_debug ("Release Objects").
RELEASE OBJECT chConnProps.
RELEASE OBJECT chReport.
RELEASE OBJECT chApplication.

ASSIGN chConnProps = ?
chReport = ?
chApplication = ?.

END PROCEDURE.
Thank in advance
 

WillieG

New Member
In some circumstances I also found that a handle is no longer valid in a sub-procedure. What I did was to define another handle in the main procedure and to assign the new handle equal to the handle I need before I call the sub-procedure. In the sub-procedure you need to replace the handle (chCtrlFrame) with the new handle. I don't know the rest of your code, but you would most probably find that chCtrlFrame were defined in another sub-procedure and not in the main procedure.
 
Hi WillieG,

Thank you for your reply, but still i cant solve. Can you share your code to solve your problem?

Thank in advance!
 

WillieG

New Member
DEFINE VARIABLE newhandle AS HANDLE. /* Add to your code */
... Rest of main procedure ...


/* Sub-Procedures */
PROCEDURE xxxxx:
DEFINE VARIABLE chCtrlFrame AS HANDLE.
chCtrlFrame = ....

..... the rest of your code here just before you call sub-procedure viewreport.....

ASSIGN newhandle = chCtrlFrame:HANDLE. /* Add to your code */
RUN viewreport.....
END PROCEDURE.

PROCEDURE viewreport:

Change all the references you made to chCtrlFrame to newhandle in this sub-procedure......

/* Example of some adjustable parameters */
MESSAGE "VALID-HANDLE (newhandle) IS: " + UPPER(string(VALID-HANDLE (newhandle))) VIEW-AS ALERT-BOX. /* Change the HANDLE name */

newhandle:CrystalActiveXReportViewer:EnableNavigationControls = TRUE. /* Enables the CRViewer's Navigation Controls */ /* Change the HANDLE name */

newhandle:CrystalActiveXReportViewer:EnableExportButton = TRUE. /* Enables the CRViewer's Export button */ /* Change the HANDLE name */

newhandle:CrystalActiveXReportViewer:EnableSearchControl = FALSE. /* Disables the CRViewer's Search control */ /* Change the HANDLE name */

/* Set the report source */
newhandle:CrystalActiveXReportViewer:ReportSource = chReport. /* Change the HANDLE name */

/* View the report */
newhandle:CrystalActiveXReportViewer:ViewReport(). /* Change the HANDLE name */

END PROCEDURE.


It could either be this, or your HANDLE chCtrlFrame was never initiated or it was disabled in the calling procedure /sub-procedure before
"RUN viewreport" was triggered.

Hope you find your problem.
Lots of Luck
WillieG
 
Top