Board index » delphi » TMemoField OnValidate's but Value = ''

TMemoField OnValidate's but Value = ''

I have a TMemoField in a TDBMemo. The TMemoField has an OnValidate event
which gets fired when tabbing out of the control. However, the value of the
TMemoField at that point is set to '' (i.e. empty string) even if the user
has typed something into the DBMemo. Oddly though, checking IsNull for
TMemoField returns False which would be OK to use, but I want to make sure
the user hasn't just entered spaces (blanks) which would also return IsNull
as False so I need to know the actual value of the field at the time it
enters the OnValidate method.

Only following when the OnExit event of the DBMemo gets called does the
Field.Value of the DBMemo show the text the user has entered. By then it is
too late as the OnValidate has already fired.

How can I ensure when the TMemoField.OnValidate method is called that the
Value of the TMemoField is up to date (i.e. equals what the user has type
in)?

NB. I realise I could get the value from the DBMemo, but don't want to do
that as it will explicitly tie the user interface tier to the
database/table/field tier. I want the validation in my datamodule to be
independent of whatever form might be using it.

TIA,

Peter
UK

 

Re:TMemoField OnValidate's but Value = ''


It happened to me too. I just couldn't read the field's value even the user
has changed it. I use a workaround like this

If (Length(DBMemo11.Text) = 0) Then NotChanged Else UserChangedIt;

Regards
Celal

"Peter Lunn" <pe...@nospamdbsfinsys.co.uk>, haber iletisinde tunlary
yazdy:3e3e7...@newsgroups.borland.com...

Quote
> I have a TMemoField in a TDBMemo. The TMemoField has an OnValidate event
> which gets fired when tabbing out of the control. However, the value of
the
> TMemoField at that point is set to '' (i.e. empty string) even if the user
> has typed something into the DBMemo. Oddly though, checking IsNull for
> TMemoField returns False which would be OK to use, but I want to make sure
> the user hasn't just entered spaces (blanks) which would also return
IsNull
> as False so I need to know the actual value of the field at the time it
> enters the OnValidate method.

> Only following when the OnExit event of the DBMemo gets called does the
> Field.Value of the DBMemo show the text the user has entered. By then it
is
> too late as the OnValidate has already fired.

> How can I ensure when the TMemoField.OnValidate method is called that the
> Value of the TMemoField is up to date (i.e. equals what the user has type
> in)?

> NB. I realise I could get the value from the DBMemo, but don't want to do
> that as it will explicitly tie the user interface tier to the
> database/table/field tier. I want the validation in my datamodule to be
> independent of whatever form might be using it.

> TIA,

> Peter
> UK

Other Threads