Subject Re: [IBO] Event Misfiring
Author Helen Borrie
At 12:59 PM 01-03-01 -0800, you wrote:
>Greetings,
>
>The following event throws an AV w/out the first line of code:
>
>procedure TdmVessels.dsVNotDataChange(Sender: TIB_StatementLink;
> Statement: TIB_Statement; Field: TIB_Column);
>begin
> If NOT Assigned(Field) then Exit;
> ShowMessage('dsVNotDataChange: ' + Field.FieldName);
>end;
>
>
>Seems like this event is firing way too early, even before the Field has
>been assigned?
>
>Comments?
>
>Kevin

The Fields[] array is created when the dataset is prepared. You get the AV if you try to refer to it before it is instantiated. The safer way to go is to use FieldByName, as it automatically tests Prepared and does the Prepare for you if necessary.

If you want to stay with Field.Prop, add this:

procedure TdmVessels.dsVNotDataChange(Sender: TIB_StatementLink;
Statement: TIB_Statement; Field: TIB_Column);
begin
if not Statement.Prepared then
Statement.Prepare;
ShowMessage('dsVNotDataChange: ' + Field.FieldName);
end

Cheers,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________