Results 1 to 4 of 4
  1. #1
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95

    Help with datetime field in subform

    I hope the following makes sense.

    I have a form called "Task Details" with a subform called "tblTaskTimes subform". The subform is nothing more than a table to log "Start" and "End" times for the task. However, there are interruptions throughout the day and so I've added in a pause command button that inserts Now() into the end time. I then also inserted a Restart that adds a new record and puts the datetime into the start field for resuming the task.

    The problem I'm having is the finish or even if there is a second pause for this task, it is overriding the first occurance of the end time and not onto the last record. I'm trying to incorporate the DMax to look at the ID, but I've had absolutely no luck getting this to work.

    Private Sub cmdPaused_Click()
    Me.tblTaskTimes_subform!End = Now()
    End Sub

    Any help would be greatly appreciated.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I use a reference to figure out how to refer to controls on forms and subforms.
    See http://access.mvps.org/access/forms/frm0031.htm

    If you are on the main form and refer to a control on the subform, you might try:
    Code:
    Me.tblTaskTimes_subform.Form!End = Now()
    Note that
    1) "End" is a reserved word in Access and shouldn't be used for object names. (also "Start")
    2) "End" is not descriptive. End of what? A better name might be "TaskEnd" (and "TaskStart")

  3. #3
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95
    I had no idea these were reserved words, thanks. (Although I am a complete novice). I changed to StartTime and EndTime, and have added in the form. The command button is just updating the original EndTime and not on a new row.

    Me.tblTaskTimes_subform.Form!EndTime = Now()

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Would have to see the code for the buttons.
    Or you could post the dB for analysis. Compact and Repair, then zip it before attaching.

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

Similar Threads

  1. Help with rounding datetime
    By Delta729 in forum Access
    Replies: 10
    Last Post: 04-03-2015, 12:13 PM
  2. Dateserial and datetime
    By webisti in forum Access
    Replies: 1
    Last Post: 06-17-2013, 11:31 AM
  3. DateTime Difference Query help?
    By Astron2012 in forum Queries
    Replies: 6
    Last Post: 04-27-2012, 10:24 PM
  4. How Do I Remove "Time" from a Datetime Field
    By James Parker in forum Queries
    Replies: 4
    Last Post: 01-06-2012, 03:05 PM
  5. Convert text to datetime
    By kaledev in forum Queries
    Replies: 3
    Last Post: 01-28-2011, 10:21 AM

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