Results 1 to 8 of 8
  1. #1
    shylock is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Sep 2018
    Location
    Dayton, Ohio
    Posts
    100

    Split Date and Time in controls


    I have a form "Enter Downtime" with several text boxes for BeginDate, BeginTime, EndDate and EndTime, shown below.
    Click image for larger version. 

Name:	DT Form.PNG 
Views:	22 
Size:	2.2 KB 
ID:	36504
    The form is bound to a table, "DowntimeEvent" that has a date/time field for BeginDate and EndDate that contain both the Date and Time. The form loads fine except that both the date and time controls contain both the date and time. I need to be able to edit the dates and times in order to reflect the actual date and times the downtime occurred.

    How can I load only the date in the date controls and time in the time controls, edit the controls and then save them? I realize that with the form bound to the table it automatically saves the data when I tab off or exit each control. The problem is that when I tab off the BeginTime field, for instance, the BeginDate reverts to 12/30/1899 This is so for the EndDate also. The time controls revert to 0:00.

    Any suggestions?

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Format each control in the property sheet using e.g. Short date or short time.
    It will still contain the entire field but only display what you want
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    If the table Date fields have the time, why split the time off into different fields? Or don't they?
    The form can show the date and time parts separately without splitting the Date/Time into separate fields.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I've used unbound date and time textboxes and a hidden textbox bound to the date/time field. You add the date and time together in the after update events of the date and time textboxes to populate the bound control. Loading a record, you populate those controls with DateValue() and TimeValue().

    Colin, if I'm remembering correctly, you could display values that way but not edit them (more accurately, not edit them separately).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    If you use the formatting approach with bound controls, you can edit the date and time field separately.
    However as soon as you click in the control you will see both the date and time.
    Don't delete the date part from the time control or it will revert to 30 Dec 1899.
    Potentially rather confusing to use I agree.

    Personally I would either display both date and time in the same control or use 2 unbound controls and concatenate the data into the combined field.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    shylock is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Sep 2018
    Location
    Dayton, Ohio
    Posts
    100
    Paul:

    Thanks for the input. I solved the problem by placing an "Edit" button on the "Enter Downtime" form. When clicked it pops up an Edit form for the dates and times. This pop up form has an "Update" button that, when clicked concatenates the dates and times and returns them to the appropriate controls on the "Enter Downtime" form. Kind of a funky way to do this but I agree with Colin that it could be confusing to the users to edit the dates and times, directly, in the "Enter Downtime" form.

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Glad you have a solution.
    For info, that is what I meant by
    use 2 unbound controls and concatenate the data into the combined field.
    You've just done that on a popup form
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by shylock View Post
    Paul:

    Thanks for the input. I solved the problem by placing an "Edit" button on the "Enter Downtime" form. When clicked it pops up an Edit form for the dates and times. This pop up form has an "Update" button that, when clicked concatenates the dates and times and returns them to the appropriate controls on the "Enter Downtime" form. Kind of a funky way to do this but I agree with Colin that it could be confusing to the users to edit the dates and times, directly, in the "Enter Downtime" form.
    I wouldn't have bothered with the popup, but glad you got it sorted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 09-16-2018, 04:58 PM
  2. Split Forms and Tab Controls/Navigation Panes
    By McArthurGDM in forum Forms
    Replies: 5
    Last Post: 10-27-2014, 12:53 PM
  3. Replies: 11
    Last Post: 07-20-2014, 06:22 PM
  4. Replies: 1
    Last Post: 03-13-2014, 07:23 PM
  5. Split string into Date and Time Columns?
    By Hobbes29 in forum Queries
    Replies: 2
    Last Post: 06-08-2010, 06:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums