Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

JAVIERTB   Please read this.

Posted on 1997-04-29
1
Medium Priority
?
178 Views
Last Modified: 2010-04-04
Hello 'Javiertb',  Recently you replied to my question concerning how to handle an EConvert error from a TDateField, preferrably at the component level. I just want a simple way to clear the date field to '' on entry of an invalid date. Thank you for your reply but unfortunately it was erased by the Experts Exchange before I could read it, can you reply again please?
0
Comment
Question by:frog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
javiertb earned 100 total points
ID: 1335786
No problem, here you go:

You have to use the Fields Editor to access the TDateField events and then the code for the OnSetText is the following:

  // TDateField is Date1 and it has an edit mask !99/99/9999;1;_

  procedure TForm1.Table1Date1SetText(Sender: TField;
                                      const Text: string);
  begin
     try
          Table1Date1.AsDateTime:=StrtoDate(text);
     except

        // if date is left blank, don't show error message
        if (text<>' / / ') then
              ShowMessage('Date Error');

        // leave a blank date when error raised
        Table1Date1.AsString:='';
      end;
  end;

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question