Board index » off-topic » Getting aggregate value during OnCalcFields

Getting aggregate value during OnCalcFields


2007-07-06 10:21:36 PM
off-topic18
I need to use an aggregate field value during an OnCalcFields event but
when the event is fired, the aggregate is null because probably it
wasn't computed yet.
Do you have any ideas to workaround this?
Thanks.
--
Erick Sasse
 
 

Re:Getting aggregate value during OnCalcFields

Erick Sasse wrote:
Quote
I need to use an aggregate field value during an OnCalcFields event
but when the event is fired, the aggregate is null because probably it
wasn't computed yet.

Do you have any ideas to workaround this?

Thanks.
OnCalcFileds event fired in different situations.
If you mean dataset in dsIntenalCalc state then i think there is no
workaround.
--
 

Re:Getting aggregate value during OnCalcFields

Elohim Meth wrote:
Quote
If you mean dataset in dsIntenalCalc state then i think there is no
workaround.
Thanks.
But I really need to put the value of the aggregate field in another
calculated field. Any suggestions?
The first idea that comes to mind is to use a clone CDS with the
aggregate field. Maybe it could work?
--
Erick Sasse
 

{smallsort}

Re:Getting aggregate value during OnCalcFields

Erick Sasse wrote:
Quote
Elohim Meth wrote:

>If you mean dataset in dsIntenalCalc state then i think there is no
>workaround.

Thanks.
But I really need to put the value of the aggregate field in another
calculated field. Any suggestions?

The first idea that comes to mind is to use a clone CDS with the
aggregate field. Maybe it could work?
Need more information:
1) Calculated or InternalCalculated fields you talk about?
OnCalcFields event used for both of them.
(what is Dataset.State value in event?)
2) What actions caused OnCalcFields event:
Open, Post, MoveBy or what?
--
 

Re:Getting aggregate value during OnCalcFields

Erick Sasse wrote:
Quote
Elohim Meth wrote:

>If you mean dataset in dsIntenalCalc state then i think there is no
>workaround.

Thanks.
But I really need to put the value of the aggregate field in another
calculated field. Any suggestions?

The first idea that comes to mind is to use a clone CDS with the
aggregate field. Maybe it could work?
Also where is some difference how you obtain aggregate value:
1) Aggregate.Value
2) AggField.Value
--
 

Re:Getting aggregate value during OnCalcFields

Elohim Meth wrote:
Quote
1) Calculated or InternalCalculated fields you talk about?
OnCalcFields event used for both of them.
(what is Dataset.State value in event?)
I'm using InternalCalc but could change to Calculated if that helps.
Quote
2) What actions caused OnCalcFields event:
Open, Post, MoveBy or what?
I'm not sure. I just need the field calculated. :)
--
Erick Sasse
 

Re:Getting aggregate value during OnCalcFields

Elohim Meth wrote:
Quote
Also where is some difference how you obtain aggregate value:
1) Aggregate.Value
2) AggField.Value
I'm using the first one, but could change if it helps.
--
Erick Sasse
 

Re:Getting aggregate value during OnCalcFields

Erick Sasse wrote:
Quote
Elohim Meth wrote:

>1) Calculated or InternalCalculated fields you talk about?
>OnCalcFields event used for both of them.
>(what is Dataset.State value in event?)

I'm using InternalCalc but could change to Calculated if that helps.

>2) What actions caused OnCalcFields event:
>Open, Post, MoveBy or what?

I'm not sure. I just need the field calculated. :)
Hmmm there is huge difference between calc and internalcalc
Calcs values are not persistent across different records.
They are calculated each time you switch position in dataset.
Internal calcs values are persistent and calculated, when you
open dataset, modify record, rollback changes etc.
So to help you further you must describe your task.
May be there are some other solutions to achieve what you want than
to use aggregates and calc fields.
--
 

Re:Getting aggregate value during OnCalcFields

Elohim Meth wrote:
Quote
So to help you further you must describe your task.
I just need to recalc when a record is added, modified or deleted.
--
Erick Sasse
 

Re:Getting aggregate value during OnCalcFields

Erick Sasse wrote:
Quote
Elohim Meth wrote:

>So to help you further you must describe your task.

I just need to recalc when a record is added, modified or deleted.
Then i think you better use afterinsert, afterpost and afterdelete
events. There you can read aggregate value and update your internalcalc
field.
--
 

Re:Getting aggregate value during OnCalcFields

Elohim Meth wrote:
Quote
Then i think you better use afterinsert, afterpost and afterdelete
events. There you can read aggregate value and update your
internalcalc field.
And the first time load the field in the AfterOpen?
--
Erick Sasse
 

Re:Getting aggregate value during OnCalcFields

Erick Sasse wrote:
Quote
Elohim Meth wrote:

>Then i think you better use afterinsert, afterpost and afterdelete
>events. There you can read aggregate value and update your
>internalcalc field.

And the first time load the field in the AfterOpen?
Yes i think so.
--
 

Re:Getting aggregate value during OnCalcFields

Elohim Meth wrote:
Quote

Yes i think so.
Ok, I'll try, thanks.
--
Erick Sasse
 

Re:Getting aggregate value during OnCalcFields

Elohim Meth wrote:
Quote
Yes i think so.
It works! Thanks for your help. :)
--
Erick Sasse