Solved

JAVIERTB   Please read this.

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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