Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sfreports error
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Stonefield
Titre:
Divers
Thread ID:
00509712
Message ID:
00510550
Vues:
14
Hi Nick,

How did you define the calculated field - through SDT or in the

If you use SDT, you can define calculated fields in the Extended Table Designer. Don't forget to create Reportable and Sortable properties for calculated fields and set them to .T. for those calculated fields you want the user to report or sort on.

If you used FillFieldColllection(). Your code should look something like this.

local loCursor, ;
loField

* Do the default behavior.

dodefault()

* Add a calculated field to the field collection if the ORDITEMS table exists
* (it might not be in the current data group) and the calculated field isn't
* already there (it may have been loaded from the meta data table).

loCursor = This.oCursorCollection.Item('ORDITEMS')
if not isnull(loCursor)
loField = This.oFieldsCollection.Item('ORDITEMS.TOTAL_PRICE')
if isnull(loField)
loField = This.oFieldsCollection.AddItem('ORDITEMS.TOTAL_PRICE')
with loField

* Define the caption, expression, alias it belongs to, and alias caption for
* the field.

.cCaption = 'Total Price'
.cFieldExpr = 'ORDITEMS.QUANTITY * ORDITEMS.UNIT_PRICE'
.cAlias = 'ORDITEMS'
.cAliasCaption = loCursor.cCaption

* Define the data type, size, and input mask for the field.

.cFieldType = 'N'
.nFieldLen = 11
.nFieldDec = 2
.cInputMask = '99,999,999.99'
.cFormat = '$'

* Set nOrder to a high value so it appears at the end of the ORDITEMS fields.

.nOrder = 99

* Specify that this is a calculated field and populate the array of fields that
* make up the calculation.

.lCalculated = .T.
dimension .aCalcFields[2]
.aCalcFields[1] = 'ORDITEMS.QUANTITY'
.aCalcFields[2] = 'ORDITEMS.UNIT_PRICE'
endwith

* Save the field in the meta data.

.oFieldsCollection.SaveItem(loField)
endif isnull(loField)
endif not isnull(loCursor)

As you can see from this code, the important properties of the field object to consider for calculated fields are aCalcFields, cFieldExpr, and lCalculated. Any fields in cFieldExpr must be aliased or SFReports will ignore the field (or worse, give an error when trying to use it).

Yuanitta
Senior Consultant
Stonefield Systems Group Inc.
www.stonefield.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform