Board index » delphi » TDBEdit with a masked datefield

TDBEdit with a masked datefield

How do you delete a date value in a TDBEdit with a fieldmask set like '  -
-  '
When I use the Del-key I get an errormessage saying it's not a valid date!

 

Re:TDBEdit with a masked datefield


I ran into the same problem long ago.

  Try the following

 .  Right click on your tdatabase and add the fields you need

 .  Manipulate/Check your data in the OnSetText event

 .  You  might like to catch the exception in case of a conversion error
and then call the following
    (sender as Tfield).Clear; // in case of exception in the OnSetTExt
event.
    Example..

// You can go ahead and save your mask or literal characters nOw!.
procedure Tdm1.ConvertDate(Sender: TField; const Text: string);
begin
  try
    (sender as TField).value:= strToDate(text);
  except
  on EConvertError do
     begin
       sender.clear;
     end;
  end;{try}

Harrie Rooymans <harrie.rooym...@tip.nl> wrote in article
<01bc363d$3483f760$LocalHost@t019798>...

Quote
> How do you delete a date value in a TDBEdit with a fieldmask set like '
-
> -  '
> When I use the Del-key I get an errormessage saying it's not a valid
date!

Other Threads