smiler44
10-25-2009, 01:43 PM
I want to check to see if the user has entered data into a textbox in the format of 00:00 when the textbox loses focus. They may have entered 08:15 which is ok.
Is there one "formula" (macro) to do this?
my attempts have me having to check the 08 to see if it is numeric, then the : and then 15 to see if it is numeric.
smiler44
wiklendt
10-25-2009, 04:08 PM
why not make the data type for that field "date/time" with the format of "short time" ? then access does the checking for you...
smiler44
10-26-2009, 03:45 AM
wilklendt,
I'm using Excel. Have I misunderstood?
smiler44
wiklendt
10-26-2009, 11:59 AM
wilklendt,
I'm using Excel. Have I misunderstood?
smiler44
oops, no, it is i who has misunderstood - i didn't realise i was in the excel forum... sorry.
but, excel can have similar funcitonality. which version are you using? in 2007, you first select the cells you want validated for a format, then you can select the "data" ribbon, and then the "data validation" button.
once there you can make it such that the user can ONLY put IN a time value or date value or even a pre-defined list you have made yourself. you can also have input balloon and a customised error alert message...
http://www.access-programmers.co.uk/forums/attachment.php?attachmentid=29365&stc=1&d=1256587079
i'm not sure the menu path in previous version, but i know they have it too.
(edit: this is something you'd usually setup before the data goes in, rather than a post-hoc check)
smiler44
10-27-2009, 12:39 PM
wiklendt,
thank you for your help. Alas the user is entering the time in a textbox and not a cell.
smiler44
wiklendt
10-27-2009, 02:03 PM
wiklendt,
thank you for your help. Alas the user is entering the time in a textbox and not a cell.
smiler44
drat - sorry, that was my bad again. you did say that in your first post. i'm afraid i've never used forms in excel before and will be of no assistance in this case :(
wiklendt
10-27-2009, 02:11 PM
my attempts have me having to check the 08 to see if it is numeric, then the : and then 15 to see if it is numeric.
is this method working, however?
also, are you ensuring that the "hours" portion is not only numeric, but also less than or equal to 24 (in 24-hour time) or 12 (if in 12-hour time) and whether the "minutes" portion is less than or equal to 59....?
boblarson
10-27-2009, 02:44 PM
Check this sample out and see if it helps.
smiler44
10-28-2009, 01:59 PM
wiklendt,
you raise some good points, I was not checking to see if the hours were entered in the 12 or 24 hour clock format. I'll look into this, thank you. currently I'm not checking the data being input into the text boxes, I have not got to that yet, or have I foregotten? I'm not sure.
smiler44