bound date textbox, getting date and time from user

hey guys, i've got a bound date textbox. i want to get both date AND time from the user. and i want to ensure that the user fills in the time as well, not just leave it to default of 12:00:00 AM. what's the best way to do this? am sure yall have faced this countless times before!

what i'm thinking is - for the date part i'll use Allen Browne's calendar form to fill an unbound textbox. for the time part i'll use an unbound combobox and then i'll use the after update event to join these two together an populate a bound invisible textbox.

do yall think that's the best way to do it?

how can i avoid using vba code at all? is there any way to concatenate 2 unbound textbox values into a bound textbox?

thanks guys!! = ))
Who is Participating?
Gustav BrockConnect With a Mentor CIOCommented:
No VBA is needed.

If you have a field with the combined data, you can split the date and time to the two unbound textboxes at the OnCurrent event.

  Me![txtDate].Value = DateValue([DateTime])
  Me![txtTime].Value = TimeValue([DateTime])

After update of either:

  Me![txtDateTime].Value = Nz(CVDate([txtDate]), Date) + Nz(CVDate([txtTime]), #00:00#)

Gustav BrockConnect With a Mentor CIOCommented:
You can use BeforeUpdate to check:

  Cancel = (DateValue([txtDateTime]) = CDate([txtDateTime]))

or you could use separate textboxes for date and time and check for a time of Null, then:

  datDateTime = CDate([txtDate]) + CDate([txtTime])

developingprogrammerAuthor Commented:
thanks gustav! but how do i do this without VBA? is it possible?

if i set the control source of a textbox to the joining of the 2 textboxes' values then i cannot bind that textbox to the recordsource already.

i'm trying to figure out how to do this without code = ) thanks!!
developingprogrammerAuthor Commented:
whao gustav, really cool. using the events properties of the control itself. i never thought about that. and also being able to set the Cancel variable in the events property itself. very nice. thanks for opening up my mind once again gustav! = )
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.