PDA

View Full Version : Is it possible to do a TimeDiff expression or function on a multi-selected combo box?



wedd
01-21-2011, 02:26 AM
Hi all, is it possible to do a TimeDiff expression or function on a multi-selected combo box with different times to workout the hourly difference between start times and end times in 2 separate combo box drop down lists? A combo box is displaying start times and a separate combo box is displaying end times with the results displayed in a textbox called (How many hours?). I will like the user to see the time differences in hours. Is this possible to do this using either vba, expression, query etc? If so, how can I do this? If you have any examples that show the steps that would be very useful or if you know of any websites that explains how to do this...as I am still a bit of a novice.


Thanks for your contributions :friends:

hansup
01-21-2011, 09:44 AM
Sounds to me like you have your combo bound to a multi-valued field. That's the only way I know of to create a combo box which is multi-selectable. If that's the case, I'm unsure whether you'll be able to attract any help.

But you should clarify what you want to accomplish. For example, if the user selects 8 AM and 9 AM in the first combo, and 9, 10 and 11 AM in the second combo how do you want the difference in hours calculated? Show us an example.

wedd
01-21-2011, 10:37 AM
Hansup, the first combo box per say is the starting times 10AM to 11PM and the second combo box is the finishing times 11:30 AM to 11PM. In fact, I used your example you sent me and I think it works, I'll test it.( = [FinishTime] - [StartTime]...) What I really need is a validation rule to prevent the user from mistakenly selecting a finishing time that is earlier than a starting time. Would you know of any validation rule OR TimeDiff expressions I could use to handle this problem? Thanks!

hansup
01-21-2011, 10:46 AM
Please clarify.

Must the user select the same number of items in both combos? If so, how will you enforce that ... or detect when the first combo has 2 items selected and the second has 3 selected?

How do you match selected items from the two combos to calculate the duration? In your example, is it 10 AM to 11:30 AM -> 1.5 hours and 11 PM to 11 PM -> 0 hours? Or something else?

Please give us a Yes or No answer to this question: Is your combo bound to a multi-valued field?

wedd
01-21-2011, 10:58 AM
Yes, it is 10AM to 11:30AM which the answer 1.5 hours will auto-populate in a blank text field...AND likewise with 11PM to 11PM = 0 hours will auto-populate into the same blank text field. And no the combo boxes aren't bound to a multi-valued field.

hansup
01-21-2011, 11:11 AM
Yes, it is 10AM to 11:30AM which the answer 1.5 hours will auto-populate in a blank text field...AND likewise with 11PM to 11PM = 0 hours will auto-populate into the same blank text field. I still don't understand what you intend to do when the user selects 2 items in the first combo and 3 in the second combo.

If your immediate concern is to detect when the user enters an EndTime earlier than the StartTime, try the suggestion Randy (Cregan Tur) gave you in your other thread.

And no the combo boxes aren't bound to a multi-valued field.
Then I'm lost. I don't know any way a combo can be multi-selectable unless it's bound to a multi-valued field.

Do you have a working method to retrieve the first pair of selected items from both combos, and then the second pair, and so forth?