Solved

JAVIERTB   Please read this.

Posted on 1997-04-29
1
165 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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

726 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