Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate Time with Date Picker Control 1

Status
Not open for further replies.

BrianLe

Programmer
Feb 19, 2002
229
US
In Access 2010, I'm trying to change a text box (tbxSheduleDate) to be the combination of the date (from date picker DTPicker1), and the time from a listbox (lbxHour)of hourly values. I tried the following but is doesn't work.

Private Sub lbxHour_Click()

Me!tbxScheduleDate = CVDate(Me!DTPicker1 & " " & Me!lbxHour)

End Sub

Any suggestions?

Thanks,

Brian
 
even if the date time picker only shows days it is also storing the current time. You can test this with a message box. So to add only the date from the DTP and the time you need to do something like

txtBox = (Int(Me.DTPicker) + CDate(Me.lstBox))

it automatically casts this into a date so you do not need this
cdate((Int(Me.DTPicker) + CDate(Me.lstBox)))
 
Duane,

The Hour values in the lbxHour come from a query of the table tblHour30, with fields TimeID and Hour. The Hour field is a Date/Time type and Medium Time format.

Thanks,

Brian
 
Duane, I didn't mean to make it look like I was ignoring MajP's suggestion, but I couldn't try his suggestion at the time because I wasn't at my Office 2010 computer. And since you responded first, I felt I should respond to you as soon as I could.

MajP's suggestion does work, after I changed the text box format to General Date, so I gave him a star.

Thanks to both of you.

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top