General information
Category:
Reports & Report designer
Title:
Crystal Reports 8.5 report.section error
I am trying to use the functionality in Crystal Reports 8.5 that allows you to create a report from code. I downloaded a sample VB project from the Crystal Decisions web site, which runs perfectly in VB. Then I translated it into FoxPro (not a big job <s>). The .prg runs fine till I get to the line:
crxFieldObject = crxSections("GH").AddFieldObject("{@myFormula}", 0, 0)
I get an error crxSections is not an array.
When I look at the Intellisense info on the command line it doesn't show the "AddFieldObject()" method for the "section" object.
Any Ideas?
Tevye
**************************************************************************
* program created from translating a downloaded Crystal Reports VB sample
**************************************************************************
crxApplication = CREATEOBJECT("CrystalRuntime.Application")
*Create a New Report object
crxReport = crxApplication.NewReport
*our Database object to the Reports Database object
crxDatabase = crxReport.Database
*Set our DatabaseTables object to the Tables collection of our Database object
crxDatabaseTables = crxDatabase.Tables
*Add the Customer table from our Xtremelite.mdb file
crxDatabaseTables.Add("H:\download\crystal\examples\groupformula\xtremelite.mdb", "Customer")
*Set our FormulaFieldDefinitions object to the FormulaFields collection of our report
crxFormulaFields = crxReport.FormulaFields
*Set out FormulaFieldDefinition object to our newly create formula
crxFormulaField = crxFormulaFields.Add("myFormula", "{Customer.Customer ID} & '-' & {Customer.Customer Name}")
*Check the formula
crxFormulaError=''
crxFormulaField.Check(.t., @crxFormulaError)
*If the Formula returns an error. Display it.
If Len(crxFormulaError) > 0 Then
WAIT wind "There was an error in the formula {@" + crxFormulaField.Name + "}" + CHR(13)+CHR(10)+;
"Error Returned: " + crxFormulaError
EndIf
*Add the Group to the Report
crGCAnyValue = 14
crAscendingOrder = 0
crxReport.AddGroup( 0, crxFormulaField, crGCAnyValue, crAscendingOrder)
*Set our Sections object to the Sections collection of our report
crxSections = crxReport.Sections
*Add the Formula Field to the Group Header to prove it has been grouped
*******************************************************************************
* I get stuck on the line below. I get a message "crxSections" is not an array
*******************************************************************************
crxFieldObject = crxSections("GH").AddFieldObject("{@myFormula}", 0, 0)
*******************************************************************************
*Change some properties of the field object we just added
With crxFieldObject
.Font.Bold = .t.
.Font.Size = 12
.Height = 300
.BackColor = RGB(0,0,255)
.TextColor = RGB(255, 255, 255)
EndWith
*Add a field to the details section that will show the customer's last years sales
crxFieldObject = crxSections("D").AddFieldObject("{Customer.Last Year's sales}", 4500, 0)
*Change some properties of the field object we just added
With crxFieldObject
.Font.Bold = .t.
.Font.Size = 10
.Height = 300
.TextColor = RGB(255, 0, 0)
Endwith
*******************************************************
* the code below refers to the crystal report viewer activex
* that is placed on a form
* (haven't gotten up to that part yet! <s>)
*******************************************************
*View the Report
*CRViewer1.ReportSource = crxReport
*CRViewer1.ViewReport
*Zoom the window to 100%
*CRViewer1.Zoom( 100)
* clean up the object references
crxReport = .NULL.
crxApplication = .NULL.
crxDatabase = .NULL.
crxDatabaseTable = .NULL.
crxDatabaseTables = .NULL.
RETURN
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only