Subject | Re: [IBO] REpost: OnValidateField I want field not blanked if wrong |
---|---|
Author | mmenaz |
Post date | 2001-12-16T15:23:12Z |
Sorry, I missed to specify the event handler!
It' OnValidateField, with the following code (I'm validating two fields):
procedure TdmDataModule.qryAnFornitoriValidateField(Sender: TIB_Statement;
ARow: TIB_Row; AField: TIB_Column);
begin
if (AField.FieldName = 'CODICE_FISCALE') then
begin
if not ControlloCFPIVA(AField.AsString) then
raise Exception.Create( 'Codice Fiscale ERRATO' );
end
else if (AField.FieldName = 'PARTITA_IVA') then
begin
if not ControlloCFPIVA(AField.AsString) then
raise Exception.Create( 'Partita IVA ERRATA' );
end;
end;
The problem is that, after the exception, previous field content is restored (like it happens if you enter a bad date in TIB_Date), so if you are in inserting mode, the field becomes blank again :(
The control has the focus, I enter the wrong value, type TAB, then the error box appears and the focus is restored back to the (empty) control.
Thanks a lot for your attention
Marco Menardi
It' OnValidateField, with the following code (I'm validating two fields):
procedure TdmDataModule.qryAnFornitoriValidateField(Sender: TIB_Statement;
ARow: TIB_Row; AField: TIB_Column);
begin
if (AField.FieldName = 'CODICE_FISCALE') then
begin
if not ControlloCFPIVA(AField.AsString) then
raise Exception.Create( 'Codice Fiscale ERRATO' );
end
else if (AField.FieldName = 'PARTITA_IVA') then
begin
if not ControlloCFPIVA(AField.AsString) then
raise Exception.Create( 'Partita IVA ERRATA' );
end;
end;
The problem is that, after the exception, previous field content is restored (like it happens if you enter a bad date in TIB_Date), so if you are in inserting mode, the field becomes blank again :(
The control has the focus, I enter the wrong value, type TAB, then the error box appears and the focus is restored back to the (empty) control.
Thanks a lot for your attention
Marco Menardi
--- In IBObjects@y..., Geoff Worboys <geoff@t...> wrote:
>
[... cut ...]
>
> 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