Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exiting a TMaskEdit Date field

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I have a TMaskEdit component on a form.
I've set the mask to be a date format ' / / ' from the standard selection.
I can either leave this entry blank (used as part of the building up of a dynamic query) or input a date accordingly.
I have the problem whereby if I input a date and then want to clear this date again (i.e. return to ' / / ') to exclude from the search I get the error indicating that it isn't a valid date, etc.
How can I prevent this, ie. leave the TMaskEdit following the blanking to ' / / ' ?
Any thoughts ?
Steve
 
Steve,

Have you tried overriding the DEL key in OnKeyPress? Try detecting VK_DELETE and, if found, setting Key to #0 and setting the text of your TMaskEdit to ' / / '.

(BTW, This is one area that the Delphi engineers faithfully replicated the VB behavior, meaning very few VB people use their version of the MaskEdit because it's *cough* quirky. The Delphi people duplicated the *cough* quirks.)

IME, you're better off setting an EditFormat on the Tfield or using some other validation technique as needed.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top