Board index » delphi » Getting the running total of a field in a TQuery

Getting the running total of a field in a TQuery

Hi,

I am trying to give the user a running total of an Invoice. The invoice
lines are shown in a TDBGrid and linked to a TQuery. I am trying to hook
into the OnChange of an item line value and sum the invoice so far
including the change the user just made.

For reasons I have now forgotten I am using the dbiCloneCursor function
to get a copy of the cursor and walk through it using
DbiSetToBegin and DbiGetNextRecord. I pull out the value with
CallDbiGetField.

The problem is while walking the cursor I always get the old value
(which on a new record is zero) for the field on the record the user has
changed.

This method works if the user moves off the record onto a different
record but not within fields of the same record.

I am using cashed updates and a seperate TQuery to write to the database
- later on.

Any help would be very appreciated as well as preventing further hair
loss. Surely someone has done this.

Regards Allen

 

Re:Getting the running total of a field in a TQuery


Quote
>The problem is while walking the cursor I always get the old value
>(which on a new record is zero) for the field on the record the user has
>changed.

You need to call UpdateRecord for the original dataset, which will notify
the controls associated with it to post their current values into the record
buffer.

If this alone doesn't work (I give it just under 50/50), then you will need
to post the record in order for your cloned cursor to see the changes.

-- Mark

Other Threads