Razumovsky Posted February 11, 2003 Posted February 11, 2003 Hi all, what have people used as user friendly methods to enter times? The best I can think of is actually having 2 number fields: n_hour and n_minute and then a t_AmPm text field, but then I have to create a calc to join them into a real time. That is about the only way I can think of to still be able to use a managable pop up list, but was looking for other suggestions. Thanks!
Vaughan Posted February 11, 2003 Posted February 11, 2003 I just put something together where the user enters either 2, 4 or 6 digits into a field and it's converted into 24 hour time. For instance if the user types "03" it's 3:00:00, "0330" is "3:30:00" and "033015" is 3:30:15. I guess you could change the system to look for an "a" or a "p" at the end of the string but I'll leave that to you to work out! The fields are: FTimeEntry: the field the user types into; FTime: the calc field. The calculation is thus: -- Case(Length(FTimeEntry) = 6, Time(Left(FTimeEntry, 2), Middle(FTimeEntry, 3, 2), Right(FTimeEntry, 2)), Length(FTimeEntry) = 4, Time(Left(FTimeEntry, 2), Right(FTimeEntry, 2), 0), Length(FTimeEntry) = 2, Time(FTimeEntry, 0, 0), TextToTime("")) -- The FTimeEntry field needs to have some serious field validation on it to ensure only digits are typed (no letters spaces or punctuation) otherwise it breaks. The validation calculation for FTimeEntry is: -- Case(IsEmpty(FTimeEntry), 1, IsValid( Case(Length(FTimeEntry) = 6, Time(Left(FTimeEntry, 2), Middle(FTimeEntry, 3, 2), Right(FTimeEntry, 2)), Length(FTimeEntry) = 4, Time(Left(FTimeEntry, 2), Right(FTimeEntry, 2), 0), Length(FTimeEntry) = 2, Time(FTimeEntry, 0, 0))) and Length(Substitute(Substitute(Substitute(Substitute(Substitute(Substitute(Substitute(Substitute(Substitute(Substitute(FTimeEntry, "0", ""), "1", ""), "2", ""), "3", ""), "4", ""), "5", ""), "6", ""), "7", ""), "8", ""), "9", "")) = 0, 1) -- Hope this helps.
Razumovsky Posted February 11, 2003 Author Posted February 11, 2003 Thanks Vaughan, welllll, fits the "user friendly" criteria, but lacking a bit in the "developer friendly" dept! I love how FM can do the most complicated things so easily, but you need a 34 line calc to enter the time convieniently. I would have to add another 47 lines to deal with the U.S. phobia of 13 o'clock and beyond, but I do appreciate the post though. Cheers, -Raz
Vaughan Posted February 11, 2003 Posted February 11, 2003 Users don't care how many lines of code it takes as long as it works 100%. The code I posted accepts 2, 4 and 6 character imput and includes error checking, but you could reduce it to one line by assuming a 6 character string and leaving out the validation, but the result will be garbage. To convert the algorithm to 12 hour format you need to ensure the user types either an "a" or a "p" at the end of their entry, then look for the "a" or the "p" in the calculation and add 12 hours if its a "p." Or assume that if there is no "a" or "p" typed it's am. This will make the validation harder because an a or p is allowed as the 3rd, 5th or 7th character but not in any other position. This is *really* making things complicated... User friendly generally means a *lot* of work for the developer.
Lee Smith Posted February 11, 2003 Posted February 11, 2003 Hi Vaughan, Thank you for another way to enter times. I found your solution very simple to implement, and it looks like it could solve a few user input problems. The best part is, that you have already done the hard part, by working out the calculations. All that is left for us to do, is to copy and past the calculations into the appropriate places. Of course, not everyone has named their fields the same as you, but all they need to do is run the calculations through a text editor, and do a find and replace for your field names with their own. BBEdit (or equivalent) handles this part effortlessly. Thanks Again, Lee
Razumovsky Posted February 11, 2003 Author Posted February 11, 2003 I think I might use this formula with slight modification (as Lee said, the hard work is done- Thanks!) in combination with 1 fields: t_AmPm: text field from value list "AM", "PM" validated: left(t_AmPm,1)="a" or left(t_AmPm,1)="p" For validation of the whole thing, I would wrap the following case statement around the original calc (replace FTime with Vaughans post above in the following calc to have it all done in one field, or create this calc as the real display that just references Ftime). Case( isempty(FTime), texttotime(""), FTime < TextToTime("13:00:00")and FTime >= TextToTime("12:00:00") and left(t_AmPm,1) = "a", FTime - TextToTime("12:00:00"), FTime < TextToTime("12:00:00")and left(t_AmPm,1)="p",FTime +TextToTime("12:00:00"), FTime) This will let the user type in times in 2,4, or 6 digit entries in the 24 hour format, or in the 12 hour format and tabbing once to t_amPm and hitting "a" or "p". The resulting time would be displayed in 12 hour format on the layout. Adds an extra tab in data entry for those who can not add 12, but I think an acceptable compromise. Thanks again for doing the leg work on this one Vaughan! -Raz
Recommended Posts
This topic is 7957 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now