Results 1 to 9 of 9
  1. #1
    Chris1112 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    31

    Separating Date and Time into Two Input Fields

    I'm trying to separate a single general date field into a "date" and "time" field on a form. When I use "1stWalkDate: Format([1stWalk],"dd/mm/yy")" in a query, the field is no longer updateable.



    Ideally I would like to use the date picker along with a 30-minute interval time combo box.

    Thanks in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    What I do is put the two values into the textboxes when I load the record (this happens to be from a recordset):

    Forms!frmreservation.txtReqDate = DateValue(rst!ReqDateTime)
    Forms!frmreservation.txtReqTime = TimeValue(rst!ReqDateTime)

    and put them back together (this presumes a form with a bound date/time field):

    Me.ReqDateTime = DateValue(Me.txtReqDate) + TimeValue(Me.txtReqTime)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Chris1112 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    31
    Thanks Paul,

    For your values, I'm assuming you keep a hidden text field to display the date and time, separate it into two text boxes, then use the After Update event to recombine them?

    Thanks

  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,652
    Yes, the after update event of both the date and time controls.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Chris1112 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    31
    Sorry for slow reply, but I'm having issues with this. Where should the textbox values be set? I've tried on form load and every record receives the value from the first record. None of the events of the textbox itself seem to be useful for this.

    Thanks

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Sorry for the delay; was sick as a dog yesterday. Try the current event to load the values.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Chris1112 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    31
    Thanks Paul. Really appreciate the help.

    Having an issue now though. The form is continuous and every record is populated with the same information. The specific code I'm using is:

    Code:
    Private Sub Form_Current()    If IsDate([Stage5Walk1]) Then
            Me.txtStage5Date = DateValue([Stage5Walk1])
            Me.txtStage5Time = TimeValue([Stage5Walk1])
        End If
    End Sub

  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,652
    I assume those two textboxes are unbound, so you would see that behavior on a continuous or datasheet form. I've only used this technique on forms in single view. Offhand, I'm not sure how you could get around it on a continuous form, without creating fields to bind those textboxes to.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Chris1112 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    31
    Thanks again for the help Paul.

    What I've done to get around this is created an unbound text field. I then check for day, time, and year then put it all back together. It seems to work fairly well. I'm sure someone can break it since I can't account for everything, and I know it's not optimal or best practices, but it does work.

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

Similar Threads

  1. Separating VALUES in FIELDS/COLUMNS
    By taimysho0 in forum Queries
    Replies: 11
    Last Post: 11-30-2011, 05:32 PM
  2. Two Date/Time and Memo Fields
    By Luke in forum Access
    Replies: 3
    Last Post: 08-24-2011, 02:55 PM
  3. Separating a date into day, month and year
    By teirrah1995 in forum Reports
    Replies: 3
    Last Post: 07-17-2011, 02:17 PM
  4. Replies: 6
    Last Post: 01-04-2011, 05:43 PM
  5. problem in splitting Date and time fields
    By swaroop1012 in forum Queries
    Replies: 1
    Last Post: 11-22-2008, 11:29 AM

Tags for this Thread

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