Subject Re: [IBO] REpost: OnValidateField I want field not blanked if wrong
Author Geoff Worboys
> I've a code like:
> if (AField.FieldName = 'CUSTOMER_CODE') then
> begin
> if not IsCustCodeOk(AField.AsString) then
> raise Exception.Create( 'WRONG customer code' );
> end;
> When the error raises, the focus is put back to the offending
> control, but the field is blanked, making hard for the user to check
> and correct the long, maybe almost 99% correct, code.
> How can I have the field value preserved?

Where is this code located? (Against what event?)

I think you can avoid the problem by ensuring that focus does not
leave the control. That is; using the OnValidate event of the column
or OnValidateField event of the dataset. AFAIK this should be called
just before exit from the control (when the column update is
attempted) and so prevent focus from leaving the control - if focus
never leaves the control then it does not attempt to re-read the field
value from the column.

Let me know if this does not work.

Geoff Worboys
Telesis Computing