Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RUNNING A CRYSTAL REPORT FROM FORMS 1

Status
Not open for further replies.

goldenlam

MIS
Feb 28, 2000
12
US
Help.

Does anyone have any examples of how to run a Crystal report from a form. I have found some articles in Metalink but they are not complete. The doc they describe on Metalink also does not exist any more.

Please help on this issue.

Thanks
 
have you or anyone figured it out? This would help our group out tremendously due to the fact that they favor Crystal reports .... let me know
 
We are going the round-about way. One of the developers created a MS-VB wrapper that calls the Crystal report. Then, we are going to use the Oracle HOST command to call the VB object and pass the parms needed.

gl
 
In forms there is a function called run_product. What it does is it calls a report into forms which is what you want. You might need to look into this fucntion too called create_pramameter_list. You can find this in the forms help menu
 
run_product only support developer products so your can't use it for crystal report. You can it through "host" command but it will take more time then calling developer report. Oracle Reports is more quick and effiecient then Crystal.
 
The below set of instructions is what I wrote for our application, you should be able to figure it out from this.

Good Luck!
Jeff

1) In layout editor, create a new data block and name it OCXBLOCK
2) In property palette for the block set Records -> Single Record to Yes and Database -> Database Data Block to No
3) Create a new ActiveX control in the OCXBLOCK data block
4) Right-click on control and click Insert Object...
5) Select Crystal Report Control from Insert Object dialog and click OK.
6) In Object Navigator, double-click the new ActiveX object to display the Property Palette.
7) Change General -> Name to CRYSOCX and Database -> Database Item to No and Physical -> Visible to No
8) On Program menu select Import OLE Library Interfaces...
9) Select Crystal.CrystalReport from Import OLE dialog, select (highlight) all methods and properties, click OK.
10) Enter code into the KEY-PRINT trigger on the form similar to the following:

Code:
/*
** Invoke Crystal Report Control to perform the
** print function for this form.
*/
DECLARE
	sReportName			VARCHAR2(64);
	sReportDesc			VARCHAR2(50);
	sReportTable			VARCHAR2(64);
	sReportPath			VARCHAR2(64);
 	sUserName			VARCHAR2(16);
 	sPassWord			VARCHAR2(16);
 	sDataBase			VARCHAR2(64);
 	sConnect			VARCHAR2(96);
 	sWhere				VARCHAR2(64);
 
BEGIN

  -- Retrieve the Log in information.
  sUserName := GET_APPLICATION_PROPERTY (USERNAME);
  sPassWord := GET_APPLICATION_PROPERTY (PASSWORD);
  sDataBase := GET_APPLICATION_PROPERTY (CONNECT_STRING);
  sConnect := 'DSN=' || sDataBase || ';UID=' || sUserName || ';PWD=' || sPassWord || ';DSQ=';

-- Retrieve the report information
SELECT RPT_PATH, RPT_FILENAME, RPT_DESC, RPT_TABLE_NAME INTO
       sReportPath, sReportName, sReportDesc, sReportTable FROM
       RPT_LIST WHERE RPT_NBR = 201;

-- Set the OCX up to execute
  CRYSTAL_CRYSTALCTRL.ReportFileName(:item('OCXBLOCK.CRYSOCX').interface, sReportPath || sReportName);
  CRYSTAL_CRYSTALCTRL.WindowTitle(:item('OCXBLOCK.CRYSOCX').interface, sReportDesc);
  CRYSTAL_CRYSTALCTRL.WindowState(:item('OCXBLOCK.CRYSOCX').interface, CRYSTAL_CONSTANTS.crptMaximized);
  CRYSTAL_CRYSTALCTRL.ole_Connect(:item('OCXBLOCK.CRYSOCX').interface, sConnect);

-- Load the arguments - this section should be set to be specific to each form

  sWhere := '{' || sReportTable || '.CHAIN_NBR}=' || TO_CHAR(:SLSCHAINPF.Chain_Nbr);
  CRYSTAL_CRYSTALCTRL.SelectionFormula(:item('OCXBLOCK.CRYSOCX').interface, sWhere);

  -- Execute the report!
  CRYSTAL_CRYSTALCTRL.Action(:item('OCXBLOCK.CRYSOCX').interface, 1);

EXCEPTION
  WHEN OTHERS THEN
    MESSAGE ('An Error has occurred. ');

END;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top