Subject Re: [IBO] dataset with boolean
Author Andreas Hesse
Salvatore Besso wrote:
> hello Harvey,
>
> maybe you can use an AfterScroll event for your query:
>
> begin
> MyLookupCombo.Enabled := MyQuery.FieldByName('RELEVANT').AsBoolean
> end;
>
> Remember that to use the AsBoolean property you have to define that field as
> Boolean in the ColumnAttributes property of the query:
>
> RELEVANT=BOOLEAN
>
> or, if you want to specify also the Boolean values the field can assume:
>
> RELEVANT=BOOLEAN=1;0
>
> or
>
> RELEVANT=BOOLEAN=T;F
>
> or whatever... The True value is the first.
>
> HTH
> Salvatore
>

Or you work with properties of the column.
If the column is readonly you can open the combobox but you cannot
change the value.
So write an AfterScroll event, for example:
procedure DataAfterScroll(IB_Dataset: TIB_Dataset);
var col1,col2: TIB_Column;
begin
col1 := IB_Dataset.FindField('Relevant');
col2 := IB_Dataset.FindField('LookupKeyField');
if Assigned(col1) and Assigned(col2) then begin
col2.ReadOnly := col1.AsBoolean;
end;
end;

And don't forget to write an AfterInsert event to enable the column
there for inserts
(like code above, but only with col2.ReadOnly := false;).

To make sure that nobody could change the lookupKeyField you can write
a Before Update Trigger.

Andreas