?
Solved

"xxxxxx" is not a valid date and time

Posted on 2004-03-30
8
Medium Priority
?
3,583 Views
Last Modified: 2007-11-27
I have a form with a few DBEdits on it, which are connected to a Date-Field (Access-database).
When I fill in a non-existing date,and try to leave the DBEdit, I get the standard message "xxxxxxxxxx is not a valid date and time". How can I get rid of this message, and replace it with my own message ?

0
Comment
Question by:vanmilp
[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
8 Comments
 
LVL 11

Expert Comment

by:calinutz
ID: 10718344
try
Query1.Active:=true;
except
ShowMessage('error on date time format');
end;


Cheers
0
 
LVL 11

Expert Comment

by:calinutz
ID: 10718379
Sorry...
not paying too much attention (after 2 beers). The question is ... your DBEdits are generated from a table component? Or a Query returns the field? You should try Table if you are using a Query. Anyways you can put your "try" in the onExit Event of the DBEdit....
Cheers
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 10718524
Hello

  You can catch that on the OnSetText event of the field, to use this event you need to add the fields by double click on the table components, then right click on the field editor, then choose add field, choose the field that you want to check and write this code on the OnSetTextEvent

function IsDate(s : string) : Boolean;
begin
  try
    StrToDate(S);
    Result := True;
  except
    Result := False;
  end;
end;

procedure TForm1.Table1Event_DateSetText(Sender: TField;
  const Text: String);
begin
  if not IsDate(DbEdit4.Text) then
    MessageDlg('Enter Valid Date',mtError,[mbOk],0);
end;

IsDate a function that I use to check if a string is a valid date

Regards,
Mohammed
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Expert Comment

by:Greg Rowland
ID: 10718880
Calinutz,

Only 2 beers? what kinda programmer are you:)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10721136
>Only 2 beers? what kinda programmer are you:)
i drink no beer, because i don't like the taste,
what a programmer am i?

meikl ;-))
0
 

Author Comment

by:vanmilp
ID: 10721597
Calinutz, your solution doesn't work (I already tried that, forgot to mention it), besides that it doesn't respond to each field being edited, only to a record.

Mohammed, your solution seems to work, at least I can create the error-message for wrong input.
However, when I type in a correct date, the entered text disappears from the DBEdit ???

0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 375 total points
ID: 10721637
vanmilp, add this line to the check

  else
    Sender.Value := Text;

it will look like this

procedure TForm1.Table1Event_DateSetText(Sender: TField;
  const Text: String);
begin
  if not IsDate(DbEdit4.Text) then
    MessageDlg('Enter Valid Date',mtError,[mbOk],0)
  else
    Sender.Value := Text;
end;

Regards,
Mohammed
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 10730642
vanmilp, why grade "B", :-(
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

719 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