Board index » delphi » TField.OnValidate not fired when DS.State = dsInsert and Field.Value remains IsNull

TField.OnValidate not fired when DS.State = dsInsert and Field.Value remains IsNull

Quote
>You can leave a TField when DS.State = dsInsert and TField.Required but
>TField.Value remains IsNull.
>(User runs with Tab through fields, no changes but Field.Value = IsNull,
>validation then is on PostRecord)
>In that case, is there any way to fire the TField.OnValidate event
>before you leave the TField?

The Edit control you have attache to the tfield would have to have its modified
property set to true to trigger the Onvalidate of the Tfield.  I suppose you
could do this on entering the edit control.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

 

Re:TField.OnValidate not fired when DS.State = dsInsert and Field.Value remains IsNull


Brian Bushay TeamB schrieb:

Quote
> >You can leave a TField when DS.State = dsInsert and TField.Required but
> >TField.Value remains IsNull.
> >(User runs with Tab through fields, no changes but Field.Value = IsNull,
> >validation then is on PostRecord)
> >In that case, is there any way to fire the TField.OnValidate event
> >before you leave the TField?

> The Edit control you have attache to the tfield would have to have its modified
> property set to true to trigger the Onvalidate of the Tfield.  I suppose you
> could do this on entering the edit control.

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

The modified property set to true has no reaction. But the following (funny) source
works
and the validation is on exit field. The CustomConstraint of TField must be set
(here: VALUE <> ''),
the Required property works only on PostRecord.

procedure DBEdit_OnEnter..
...
  if (DS.State = dsInsert) and TField.IsNull
  then begin
    DBEdit.Text:= ' ';
    DBEdit.Text:= '';
  end;
...

I hope, it would exist a better solution.

W. Beugel

Re:TField.OnValidate not fired when DS.State = dsInsert and Field.Value remains IsNull


Wolfgang Beugel schrieb:

Quote
> Brian Bushay TeamB schrieb:

> > >You can leave a TField when DS.State = dsInsert and TField.Required but
> > >TField.Value remains IsNull.
> > >(User runs with Tab through fields, no changes but Field.Value = IsNull,
> > >validation then is on PostRecord)
> > >In that case, is there any way to fire the TField.OnValidate event
> > >before you leave the TField?

> > The Edit control you have attache to the tfield would have to have its modified
> > property set to true to trigger the Onvalidate of the Tfield.  I suppose you
> > could do this on entering the edit control.

> > --
> > Brian Bushay (TeamB)
> > Bbus...@NMPLS.com

> The modified property set to true has no reaction. But the following (funny) source
> works
> and the validation is on exit field. The CustomConstraint of TField must be set
> (here: VALUE <> ''),
> the Required property works only on PostRecord.

> procedure DBEdit_OnEnter..
> ...
>   if (DS.State = dsInsert) and TField.IsNull
>   then begin
>     DBEdit.Text:= ' ';
>     DBEdit.Text:= '';
>   end;
> ...

> I hope, it would exist a better solution.

> W. Beugel

ps.
How can I do this in a DBGrid.Column?

I have to do this with all attached Controls, a TField-solution would be better.

Re:TField.OnValidate not fired when DS.State = dsInsert and Field.Value remains IsNull


Quote
>How can I do this in a DBGrid.Column?

probably using the OncolumnEnter Event and the SelectedField property

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads