Solved

JAVIERTB   Please read this.

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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