Subject | Re: [IBO] Preventing a field from being updated |
---|---|
Author | Lucas Franzen |
Post date | 2001-03-15T18:13:17Z |
> Procedure TEditRequestDlg.OnValidateDecisionCode (Sender: TIB_Column );Marc,
> begin
> if (Sender.AsInteger <> CODE_DC_ACCEPTED) And (IB_QueryContributions.RecordCount > 0) then
> begin
> ShowMessage('Contributions exists ! (TODO: Delete them)');
> Abort;
> end;
> end;
>
> I though that calling an exception within the field.OnValidate would cause the change not to take place
>
> <snip>
> Event to validate the new value written to the field.
> If the new value is invalid then raise an exception to cause it to be rejected.
> <snip>
I don't see that you raised an exception in your code (Showing a message
isn't raising an exception). Have you tried to do so?
And don't use RecordCount; there are better ways to check if records
exists.
You can use:
if ( NOT IB_QueryContributions.IsEmpty )
or:
if ( NOT IB_QueryContributions.FieldbyName('PrimaryKeyField').IsNull )
instead.
Luc.