Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Crystal, FoxPro, How do they work together?
Message
From
31/07/2000 13:22:51
Walter Meester
HoogkarspelNetherlands
 
 
To
31/07/2000 10:21:47
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
00398782
Message ID:
00398887
Views:
34
Robert,

>I have been browsing this newsgroup for 3 days now and I have some questions on how to mesh Crystal Reports with VFP.
>Background: I wish to create a VFP form and from this form port the info to a CR. I currently use VFP's report writer but I am becoming very disgruntled with its performance. I will use tables generated on the fly and I will pass parameters. I am using CR 8.0 Developer, VFP 6.0 SP 3 on an NT network with SQL server 7.0 as data base repository.


The best way, seems to be to use the RDC automation server approach. This is using an engine created by createobject('crystalruntime.application').

If you want to be able to preview the report, you also need the Crystal reports Smartviewer.8 activeX control (be ware that this a different one than the Crystal reports activeX control)

Before you can call the report you must have your query results ready in FOX2X format. (Or you want to query your SQL server in the report via parameters, but this is a different issue).

Sample code:
* Open the RDC engine
oEngineObject = CREATEOBJECT("CrystalRuntime.application")

* Open the report

oReport=oEngineobject.openreport(cReportname)

* be sure your Variable (parameter) names in crystal are the same as used in VFP
* then you can use the following code to pass the paramters to CR

WITH oReport.ParameterFields
	FOR nT= 1 TO .Count
		cName=.Item(nT).ParameterFieldName
		IF TYPE(cName) # "U"
			.item(nT).SetCurrentValue(EVAL(cName))
		ENDIF
	ENDFOR
ENDWITH

* Change the location of the data into location of your created FOX2X (temp) table.
* This sample code assumes that the array aDBFFiels contains the locations of 
* the FOX2X tables used in your report in the following manner
* aDBFFiles[nI, nI]
* - The first column contains the location of the DBF file. If there are more 
* than one DBF files to be used within your report, you can add new rows for 
* each DBF file you need.
* - The second column is used when you want to change table locations in 
* subreports. Therefore the second column contains the name of the subreport.
* 
* Be sure that the files for the main report are at the beginning of the array, 
* and those of subreports grouped at the end.
* The physical order in which the tables are added in Crystal Reports determines
* the order in which they should appear in this array.

IF TYPE("aDBFfiles(1)")="C"
	nI=1
	FOR nT = 1 TO ALEN(aDbffiles,1)
		IF ALEN(aDBFfiles,2)>1 AND !EMPTY(aDBFfiles[nT,2])
			oReport=THIS.Report.Opensubreport(aDBFfiles[nT,2])
			nI=1
		ENDIF
		IF !EMPTY(aDbffiles(nT,1))
			oReport.Database.Tables.item[nI].location = aDbffiles(nT,1)
		ENDIF
		nI=nI+1
	ENDFOR
ENDIF

* O.K. Now your reports is set up. You can print it with:

oReport.Printout(lPromptUser)

* When Previewing you must include the smartviewer activeX control.
* Make it the same size as your previewing form.
* Use the following code to preview the report in the activeX control

THISFORM.CrViewer.ReportSource = oReport
THISFORM.CrViewer.Viewreport()
These are the basics to handle reports in the RDC manner within VFP. For further documentation read the Developer.hlp, somewhere in your crystal reports directory.



>--Having already gone thru the samples on UT; is there an _difinitive_ example which will show how to open up the CR, and send the parameters to the report. I have seen alot of disjointed pieces and tried to make them work all with no success.

See sample above.

>--Also how can I use the Runtime version since according to Seagate I need only buy the CR Developer's and dole the static reports to my users? Is it really necessary to copy all of the DLLs and install them on everyone's machine?

Yes, there is no way to work with CR without including runtime dlls. See runtime.hlp to determine which DLLs you need to distribute.

>--If I need to an active X object which one do I use? I have seen a mention to a 'SmartViewer' control. But when I added a control I did not see a reference to a SmartViewer control.

Yes, indeed you need the samrtviewer activeX control for previewing. When CR 8.0 is installed it is avaliable within VFP. Just press the OLE toolbutton in the form controls toolbar, place it on your form. (A dialog show up), choose insert control, and pick the Crystal Report Smartviewer 8 control.

>--What is difference between when I -- createobject('crystalruntime.application'), createobject('crystal.crystalreport'), createobject('crystal.CRPE.application')?

You instantiate two different automation servers: the RDC engine and the CRPE engine. the CRPE engine is beeing discontinued, the RDC is the new one. The are very simular, but the RDC one is even more flexible as the CRPE one. You can't mix the two approaches.

Walter,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform