Update Time portion of Date/Time Field

jmaty23

Registered User.
Local time
Today, 03:46
Joined
Jul 24, 2012
Messages
53
I have a date/time text field on a form with the General Date format and a combo box next to it that has sequencial times as the row source (IE. 12:45 AM, 1:00 AM, 1:15 AM, 1:30 AM, ETC.) When the user chooses a time in the combo box, I want the time portion of the text box to be updated with the chosen time in the combo. I have tried a few things but cant seem to get it right.

Any ideas?
 
I did this using a List Value for the 'times' in the Combobox:

Code:
Private Sub TimeCombo_AfterUpdate()
 Me.DateTimeField = CDate(DateSerial(Year(Me.DateTimeField), Month(Me.DateTimeField), Day(Me.DateTimeField))) & " " & Me.TimeCombo 
End Sub
Linq ;0)>
 
This is exactly what I needed.

Additionally, I was able to update the date portion by reversing your VBA using TimeSerial along with the DateSerial Function. Thanks for your assistance.
 
...I was able to update the date portion by reversing your VBA using TimeSerial along with the DateSerial Function...

That's called learning! Always nice to see!

Glad we could help!

Linq ;0)>
 
Not had a chance to test but couldn't you have used Datevalue instead of DateSerial, in fact Datevalue + Timevalue on the respective controls.

Brian
 

Users who are viewing this thread

Back
Top Bottom