Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2011
    Posts
    8

    HELP With Elapsed Time in Form

    Please see a screenshot of my form here:



    http://i1111.photobucket.com/albums/...work1/form.jpg

    I want the user to be able to click on the "Calculate" button, and then the text field of the "Elapsed Incident Time" shows how many hours, minutes, and seconds since the start and the end of the incident. I have the date and time separated as fields so that it looks nice for the user - does this complicate things?

    What code do I put in for the "On event - click" for the calculate button? And how do I make it so the format comes out nice, in a way that makes sense (i.e. 33 hrs, 2 mins, 43 sec)????

    HELP!! This is for work and I really need to finish it. I am really new to this so please explain to me what I have to do... as if I am three years old.

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Yes, it will make it a little harder, but it can be done.
    Try this: (UNTESTED)

    you will need the code from
    http://www.accessmvp.com/djsteele/Diff2Dates.html

    (put the "Diff2Dates" function in a standard module)

    Code:
    Private Sub cmdDoCalc_Click()
       Dim dtStart As Date
       Dim dteEnd As Date
    
    ' combine the dates/times
       dtStart = DateValue(Me.StartDate) + TimeValue(Me.StartTime)
       dteEnd = DateValue(Me.EndDate) + TimeValue(Me.EndTime)
    
    
       ' the  function Diff2Dates is from    http://www.accessmvp.com/djsteele/Diff2Dates.html
       Me.Elapsed = Diff2Dates("dhns", dtStart, dteEnd)
    
    
    End Sub
    Last edited by ssanfu; 08-31-2011 at 05:04 PM. Reason: spelling

  3. #3
    Join Date
    Aug 2011
    Posts
    8
    Wow it worked!!!!!! Thank you sooooo much I was really stressing about this!

    Thanks thanks thanks!

  4. #4
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Wonderful...
    Are you ready to mark this solved?

  5. #5
    Join Date
    Aug 2011
    Posts
    8
    Yes for sure I am! I just don't know how...

  6. #6
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Toward the top of the page is a header that starts with "LinkBack", then "Thread Tools". Click on the down arrow next to "Thread Tools". The bottom selection is "Mark thread solved".

  7. #7
    Join Date
    Aug 2011
    Posts
    8
    Done, thanks!

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

Similar Threads

  1. HELP! Elapsed Time Difference
    By accessineedhelp in forum Access
    Replies: 5
    Last Post: 08-31-2011, 06:00 PM
  2. fuction elapsed time, expression builder
    By zac123 in forum Access
    Replies: 1
    Last Post: 08-05-2011, 02:21 PM
  3. Time: How to increment time in form
    By dek in forum Forms
    Replies: 1
    Last Post: 05-07-2011, 12:47 AM
  4. Calculating Elapsed Time
    By jo15765 in forum Forms
    Replies: 8
    Last Post: 04-15-2011, 07:00 PM
  5. Time Elapsed Problem
    By leejqs in forum Reports
    Replies: 6
    Last Post: 07-16-2009, 07:58 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