Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Crystal 8.5 RDC - getting my arms around it ...
Message
From
03/06/2001 22:04:08
 
 
To
01/06/2001 21:34:26
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
00514118
Message ID:
00514396
Views:
11
This message has been marked as the solution to the initial question of the thread.
>Would someone be kind enough to point me to examples of the Crystal RDC being integrated into VFP - my initial usage will be primarily as a report engine rather than for enduser report design.
>
>I just need some 'examples' to get me started.

I've recently just been where your at right now. After many hours of searching and struggling, here is a combination of many things I've gleaned from others here, as well as a few items I've discovered on my own.

I hope this will be useful to you.

4 approaches to using CR :
- Crystal ActiveX control, too simple, not enough control
- API, too complex to handle
- CRPE automation, Advanced, much control, but development is beeing discontinued
- RDC automation, Very advanced, for maximum control, this is the way to go.

A gotcha :
The RDC is a dual interface control - which requires that you set SYS(2333,1) before creating the CR RDC report application object. (Note that SYS(2333,1) was the default value in VFP 5.0 but SYS(2333,0) is the default in VFP 6.0. Using an incorrect setting causes the c0000005: OLE object may be corrupted error.

A Suggestion on data access method from within Crystal Reports :
Use Fox 2.x table structures with IDX indexes if needed. It works well, and it's DSNless.

You must specifically add the index to the table in CR. Do this in the Visual Linking Expert by selecting a field in the table with the index, right clicking, and selecting "Add Index".

At runtime, there is no place in a CR report object to designate the IDX location. CR assumes the same IDX name as used when the report was created, and that the IDX is in the same location as the table ( which can be changed at runtime ).

At runtime write your FOX2.X tables to a temporary directory (e.g. C:\Temp\_0012345.DBF). Make sure that you write the index files to the same directory. However, beware that the name of the index must stay the same as used in the report designer. So if you used Acct.IDX as name for the index in the CR designer, you must use the same name at runtime, but place it in the same directory as the temporary table (so as: C:\Temp\Acct.idx)

Sample code using RDC and Fox2X tables :
* 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 aDBFFiles 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()

* You can also set various CrViewer options prior to showing it
* with ViewReport(), such as :

THISFORM.CrViewer.DisplayGroupTree = .F.
THISFORM.CrViewer.DisplayTabs = .F.
THISFORM.CrViewer.EnableExportButton = .T.
THISFORM.CrViewer.EnableGroupTree = .F.
THISFORM.CrViewer.EnablePrintButton = .T.

These are the basics that got me started. I've evolved this into an n-tier model now that is seeming to work well (it's still pretty new ). I'm still using the RDC with Fox2x tables.

Good Luck,

Anthony Letts
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform