Subject [IBO] Re: Accessing 'previous' values during posting/commiting
Author bamber12001
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
> At 08:47 AM 14/10/2004 +0000, you wrote:
>
>
> >--- 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;
>
> Nothing obvious...what is qryBudgetItems? Fields.Oldvalues[]
won't work if
> you are referencing a TIBOQuery. You'd need to access the
InternalDataset
> property.
>
> qryBudgetItems.InternalDataset.OldValues
['FORECAST_MARGIN'].AsString
>
> But where the automation object error comes from is anyone's
guess. Do you
> have ActiveX in the picture?
>
> Helen


Helen,

qryBudgetItems is a TIB_Query and I am not using ActiveX at all in
this program. I am running the routine in the associated
transaction's AfterCommit event - I presume this is OK?

Gary.