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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automation

Status
Not open for further replies.

Olii

Programmer
Sep 22, 2000
13
CA
Hi ! I have a report that is already created and of course, a table. The table that holds the data is filled with a .prg and I want to call crystal to preview the report at the end of this .prg. I've tried by creating an OCX but I always get and OLE error (I use a sample code found on the web). I want to know what i'm doing wrong !! I can start CR with a simple run (!) command but the report is not refreshed automatically....maybe there's a parameter that i can add to the call of the run command (like: path\report.rpt /refresh) but i dont know it !!

can someone help ??
 
Olii: You need to check that you've logged onto the data source before you try to view. Have a look at LogonServer David C. Monks
david.monks@chase-international.com
Accredited Seagate Enterprise Partner
 
The table is local and when i call the report with the run command, all I have to do is press Refresh (F5) so the access to the data source is OK. I also tought about sending F5 key to crystal to refresh it...will that work ??

If you want to see the code I use, tell me and I will e-mail or post it here for you...

thanx again for your help !
 
You don't want to start CR with the run commnand, becuase there are no command line options for the CR32.exe. To launch a report from a program you need to use one of the integration methods, like the OCX.

What language are you programming in, and what version of CR? Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
CR 8 and VFP 6 have a look at the code :

Declare RegOpenKey in ADVAPI32.DLL INTEGER, STRING, INTEGER @ID_Cle &&verify if crystal is installed
=RegOpenKey(2147483650,"Software\Seagate",@ID_Cle)

if ID_Cle # 0
*! /N start c:\windows\desktop\crystal\requetes\nouveau_rapport_req.rpt
rapport = 'c:\windows\desktop\crystal\requetes\nouveau_rapport_req.rpt'
table_result = 'c:\windows\desktop\crystal\requetes\fin_de_mois.dbf'
IF FILE(rapport) AND FILE(table_result)

=CRYSTAL_REPORT("c:\windows\desktop\crystal\requetes\nouveau_rapport_req.rpt",;
"c:\windows\desktop\crystal\requetes\fin_de_mois.dbf","",0)

**********************************************

endif
else
messagebox("Crystal Report n'est pas installé!")
endif

close databases all
FUNCTION CRYSTAL_REPORT
PARAMETERS V_CRFILE,V_TABLE,V_OUTFILE,V_OUTTYPE
PRIVATE V_CRFILE,V_OUTFILE,V_OUTTYPE,V_RTN
V_CRFILE = 'c:\windows\desktop\crystal\requetes\nouveau_rapport_req.rpt'
V_TABLE = 'c:\windows\desktop\crystal\requetes\fin_de_mois.dbf'
V_OUTFILE = 'c:\windows\desktop\test'
V_OUTTYPE = 0
V_RTN=.T.
ON ERROR V_RTN=.F.
IF FILE(V_CRFILE) AND FILE(V_TABLE)
* Create and set up the Crystal OCX
V_CRYSTAL=CREATEOBJECT("Crystal.CrystalReport")
V_CRYSTAL.REPORTFILENAME=V_CRFILE
V_CRYSTAL.WINDOWTITLE="Report Preview"
V_CRYSTAL.DATAFILES(0)=V_TABLE
V_CRYSTAL.WINDOWSTATE=2
V_CRYSTAL.PRINTFILENAME=V_OUTFILE
V_CRYSTAL.PRINTFILETYPE=V_OUTTYPE
V_CRYSTAL.DESTINATION=0
V_CRYSTAL.WindowShowGroupTree=.T.
V_CRYSTAL.WindowShowSearchBtn=.T.
V_CRYSTAL.WindowShowCloseBtn=.T.
V_CRYSTAL.ACTION=1

* This isn't required, as we have V_CRYSTAL
* as PUBLIC ABOVE
IF V_OUTTYPE=0
*!* This is required to stop the procedure
*!* from dropping out during a preview.
=MESSAGEBOX("Holding report preview, press OK " + "to continue",64,"CrystFox")
ENDIF
ELSE
V_RTN=.F.
=MESSAGEBOX("Missing Crystal report or Fox2x table!",48,"CrystFox")
ENDIF

ON ERROR
RETURN V_RTN
****************************************

 
Does the original report connect to the table via ODBC (DSN)? Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Yes the report connects via ODBC....but do you have a way of refresh the report automatically when it is called ??

like an extra parameter ...cause i can launch the .rpt via a run command but the report is not in preview mode so I want to make that automatic.

Thanx!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top