![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 3 of 3 total |
![]() |
Sat, Dec 29 2007 6:47 AM | Permanent Link |
Peter van Mierlo | hi,
My database has some timefield. Now i would like to use a DBEdit for entering time (no DateTimePickers). So i can set the editmask and that works...BUT...when the user enters a time like 33:45 then i got back a error '33:45 is not a valid time'. That correct, but i would like to have my own message. I readed some stuff about OnSetText and did the following : Define function like this : function IsTime(cStageTime: string): Boolean; The function is : function TdmEvent.IsTime(cStageTime: string): Boolean; var dt: TDateTime; begin Result := true; try dt := StrToTime(cStageTime); except Result := false; end; end; In the OnSetText event of the field where the user enters his new time i do this : cStageTime:=dmEvent.qry_artist.FieldByName('act_stage_time').asString; if IsTime(cStageTime) then begin ShowMessage('Correct stage time'); dmEvent.qry_artist.FieldByName('act_stage_time').value:=cUur; end; In the OnSetText you need to set the new value, but i can't figure out why this is not working. What i need is a check for a valid time and when it's NOT correct i display a message, and when it's correct, just accept the new value in the database. Has anyone suggestion or a solution how to deal with valid time check. It has costs me a lot of time and i can't see whats wrong...a other solution would be a dbcombobox with al time value like 00:00, 00:15, 00:30 but thats the last option i preferred. Greetz Peter |
Sat, Dec 29 2007 7:21 AM | Permanent Link |
Fernando Dias ![]() | Peter,
This is what I use to do what you want, for time and date fields (the field name here is "TNCliAgHora"): procedure TdmCli.TNCliAgHoraSetText(Sender: TField; const Text: string); begin if trim(Text)=':' then Sender.Clear else try Sender.AsDateTime:=StrToDatetime(Text); except // custom message when the time is invalid raise exception.Create('"'+text+'" is not a valid time!'); end; end; Happy new year! -- Fernando Dias Easygate, Lda |
Sat, Dec 29 2007 7:55 AM | Permanent Link |
Peter van Mierlo | Hi Fernando,
That it could be so easy...works for me...thanks and a happy new year greetings Peter Fernando Dias <fernandodias.removthis@easygate.com.pt> wrote: Peter, This is what I use to do what you want, for time and date fields (the field name here is "TNCliAgHora"): procedure TdmCli.TNCliAgHoraSetText(Sender: TField; const Text: string); begin if trim(Text)=':' then Sender.Clear else try Sender.AsDateTime:=StrToDatetime(Text); except // custom message when the time is invalid raise exception.Create('"'+text+'" is not a valid time!'); end; end; Happy new year! -- Fernando Dias Easygate, Lda |
This web page was last updated on Wednesday, August 14, 2024 at 07:31 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |