Time Chooser

G

Guest

I would like to use 3 combo boxes to choose the time for my bound textbox;
Hour, Minutes (by the quarter hour), and AM/PM.

My bound textbox txtStartTime (default value is 08:00 AM)

cboHour: would be a value list of 1-12 (representing the hours)
cboMinute: would be a value list (00, 15, 30, 45)
cboAMPM: would be a value list (AM, PM)
As soon as I select either of the time values I would like the textbox to
reflect this change.

Thanx!
 
D

David W

Try this, it might work
Put this code in the after update event of all 3 comboboxes
Make Sure you limit the lists of the comboboxes to keep unwanted entries
out.


Dim myTime

myTime = Me.cboHour & ":" & Me.cboMinute & Me.cboAMPM
Format(Me.myTime, "hh:mm AM/PM")
Me.txtStartTime = myTime

Hope this helps!
 
R

Ron Weiner

I might try it like this

txtStartTime = CDate(Nz(cboHr, 0) & ":" & Nz(cboMin, 0) & Nz(cboAP, "AM"))

This handles nulls in the combos gracefully, and converts the value in the
text box to a DateTime data type. You can set the format property of the
text box to display the resulting time in any format you like, but the
underlying data remains a DateTime on which you can peform date math or
sort by in some other process in your app.
 
P

PC Datasheet

Look at the TimeSerial function in the Help file. It works for time just
like the DateSerial function works for dates.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

If you don't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top