It's probably a silly question, but how do I use an aggragate function with Zeos?
I dropped a TZQuery on a form, added a query and created an aggregated field TOTAL. After this I linked a dbgrid to a datasource, that I linked to ZQuery1. After this the 'normal' fields are visible in the dbgrid, and I would like to bind a textbox to the TOTAL. But how must I do this? The value seems to be allways empty. Next to this, if I would make a change in the SUBTOTAL field in the dbgrid, how is the TOTAL recalculated?
A piece of code from the datamodule.dfm :
Code: Select all
object ZQuery1: TZQuery
Connection = ZConFirebird
BeforeScroll = ZQryVerwerkingsdatumBeforeScroll
AfterScroll = ZQryVerwerkingsdatumAfterScroll
OnCalcFields = ZQuery1CalcFields
Active = True
SQL.Strings = (
'SELECT * FROM batches;')
Params = <>
Left = 330
Top = 368
object ZQuery1BATCH_ID: TIntegerField
FieldName = 'BATCH_ID'
Required = True
end
object ZQuery1SUBTOTAL: TFloatField
FieldName = 'SUBTOTAL'
end
object ZTOTAL: TAggregateField
FieldName = 'TOTAL'
Visible = True
OnChange = ZTOTALChange
Active = True
currency = True
Expression = 'sum(SUBTOTAL)'
end
end
Bert