Time Issue

D

David W

I have a form with 3 comboboxes that have the folowing for a value list

1st combo is an hour list from 1-12

2nd combo is a minute list from 01-59
(which doesn't want to display right, like 1 instead of 01)

3rd combo has "AM" "PM"

What I am trying to do without success is to have the user pick an hour then
a minute then either am or pm, compare them to see if they equal the system
time at some point.

How do you combine all 3 combos to come up with the time they prefer, then
compare it to the system time to see if they match.

Also, I noticed that VB said you could use "m" to distinguish minutes by
using datepart("m",Time()) or datepart("m",Now()).
It does work right if you use "h" for hour but the "m" aways returns 12 for
the minutes.
 
G

Guest

The code for minutes is "n", "m" is for month.

You would use the TimeSerial function for returning the time
The TimeSerial function works on a 24 hour clock. That is why you have to
add 12 to get PM, unless your hour is 12 and you want AM, then you have to
use 0 to get 12:00 AM

If Me.cboHour = 12 And Me.cboAmPm = "AM" Then
intHour =0
Else
If Me.cboAmPm = "PM" Then
intHour = Me.cboHour + 12
Else
intHour = Me.cboHour
End If
End If

MyTime = TimeSerial(intHour, Me.cboMinutes,0)

You have to specify seconds or the function will error, so just use 0
 

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