Subject Re: Accessing 'previous' values during posting/commiting
Author bamber12001
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
> At 03:04 PM 13/10/2004 +0000, you wrote:
>
>
> >Hi all,
> >
> >I have a database which stores budget and forecast figures. I want
> >to keep track of any changes to these figures in a text file. This
> >text file should store the before and after values, everytime a
> >record is changed.
> >
> >I know I can access the previous values using OLD and NEW in my
SQL
> >query (in the UpdateSQL section), but is there anything like this
> >available on the Delphi side of things?
> >
> >I tried using the Buffer information, but this only seemed to have
> >the new value's.
> >
> >I can obviously take a copy of the values before they are editted,
> >but I would prefer to do it a 'clever' way!
>
> Fields.OldValues['NameOfColumn'].AsString
>
> Helen


Thanks Helen, but I am getting an error 'variant does not reference
an automation object' when I try to access these fields.

Here is my procedure - can you see where I am going wrong?


procedure TCustomerBudgetCreateFRM.WriteOriginalForecastFigures;
var
monthnum: shortint;
begin
// Write the OLD figures to file
WriteLn(fileForecastBackups, 'ORIGINAL VALUES:');
qryBudgetItems.First;
for monthnum := 1 to 12 do
begin
WriteLn(fileForecastBackups, ' ' +
qryBudgetItems.Fields.OldValues['DESCRIPTION'].AsString
+ ' : Q ' +
qryBudgetItems.Fields.OldValues['FORECAST_QUANTITY'].AsString
+ ', V ' +
qryBudgetItems.Fields.OldValues['FORECAST_VALUE'].AsString
+ ', M ' +
qryBudgetItems.Fields.OldValues['FORECAST_MARGIN'].AsString);
qryBudgetItems.Next;
end;
end;



Gary.