vanmilp
asked on
"xxxxxx" is not a valid date and time
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 ?
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 ?
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
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
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_DateSet Text(Sende r: 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
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_DateSet
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
Calinutz,
Only 2 beers? what kinda programmer are you:)
Only 2 beers? what kinda programmer are you:)
>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 ;-))
i drink no beer, because i don't like the taste,
what a programmer am i?
meikl ;-))
ASKER
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 ???
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 ???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
vanmilp, why grade "B", :-(
Query1.Active:=true;
except
ShowMessage('error on date time format');
end;
Cheers