Date/time edits

  • Thread starter Thread starter Rose B
  • Start date Start date
R

Rose B

I have a date/time field in a table that I would ideally like the user to be
able to edit separately on a form - i.e. edit the date in a Date format
control and the time in a Time format control. The form display is fine but
as soon as either field is clicked the full value (date and time) is
displayed - which is very confusing for the user. Is there any way to crack
this other than actually splitting the underlying field?
 
Unless you're talking about a continuous (or datasheet) form, you could put
a couple of unbound text boxes on the form (one for the date and one for the
time), with the bound date/time textbox on the form but not visible.

In the form's Current event, assign values to the two unbound controls:

Private Sub Form_Current()

Me!MyDateOnlyTextbox = DateValue(Me!MyDateTimeTextbox)
Me!MyTimeOnlyTextbox = TimeValue(Me!MyDateTimeTextbox)

End Sub

In the AfterUpdate event of the two unbound text boxes, put code to reassign
the value to the bound field:

Private Sub MyDateOnlyTextbox_AfterUpdate()

Me!MyDateTimeTextbox = Me!MyDateOnlyTextbox + Me!MyTimeOnlyTextbox

End Sub

Private Sub MyTimeOnlyTextbox_AfterUpdate()

Me!MyDateTimeTextbox = Me!MyDateOnlyTextbox + Me!MyTimeOnlyTextbox

End Sub
 
Thanks!!!!

Douglas J. Steele said:
Unless you're talking about a continuous (or datasheet) form, you could put
a couple of unbound text boxes on the form (one for the date and one for the
time), with the bound date/time textbox on the form but not visible.

In the form's Current event, assign values to the two unbound controls:

Private Sub Form_Current()

Me!MyDateOnlyTextbox = DateValue(Me!MyDateTimeTextbox)
Me!MyTimeOnlyTextbox = TimeValue(Me!MyDateTimeTextbox)

End Sub

In the AfterUpdate event of the two unbound text boxes, put code to reassign
the value to the bound field:

Private Sub MyDateOnlyTextbox_AfterUpdate()

Me!MyDateTimeTextbox = Me!MyDateOnlyTextbox + Me!MyTimeOnlyTextbox

End Sub

Private Sub MyTimeOnlyTextbox_AfterUpdate()

Me!MyDateTimeTextbox = Me!MyDateOnlyTextbox + Me!MyTimeOnlyTextbox

End Sub
 

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

Similar Threads

Changing a Medium Time 5
Input Mask for General Date/Time 1
date time picker 4
time edit 1
Editing formatted date in textbox 3
time edit short date 7
Time field continues to show date 3
Calculating Time Values 2

Back
Top