Results 1 to 3 of 3

vba > subtracting time

  1. #1
    metokushika is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    19

    vba > subtracting time

    how do i subtract time??

    i'm trying to make a time sheet that could
    calculate the number of hours. like say
    i timed in at around 8:00 AM and i
    timed out at around 3:00 PM. how do
    i get the number of hours that i consumed
    for that day?


    i was thinking that if i do this > 12 - 8 = 4 then
    add the 3 which makes it 7. but the value doesn't
    work bec. i figured that you can't subtract an INTEGER
    to time. the answer doesn't come up right.

    OR maybe if i assign a value to each of the time,
    do you think it will work??

    EX. If Me.Text67.Text = "2:00 AM" Or Me.Text67.Text = "2:00 PM" Then
    Text67.Value = 2



    please help please help

  2. #2
    ssanfu is offline VIP
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    3,487
    We need more info.

    What is the data type of the fields in the table? (date, text, integer)
    What are the field names?
    If the data type is Date, then you would use the DateDiff() function.

    If the data type is text, integer or the controls on the form are unbound,
    then it is more involved in doing the calculation.

    BTW, rarely do you need to use the Text property of a control. The text property is actually the uncommitted (new) data of a control as opposed to the Value property (old data).
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

  3. #3
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    282
    i am using the following in a query. it's still a big work in progress but you may get an idea from it.

    SELECT [Employee Time Report Output].Expr1 AS [Date], [Employee Time Report Output].[Scan Day] AS [Day], [Employee Time Report Output].Expr2 AS [IN], [Employee Time Report Output].Expr3 AS OUT, [Lunch Tracking].[Lunch Start], [Lunch Tracking].[Lunch End], Format([tt],"h")*60+Format([tt],"nn") AS Expr5, [Employee Time Report Output].[Total Hours less Lunch (30min)], [Total Minutes]-[expr5] AS Expr4, [Employee Time Report Output].["Time and a Half "], [Employee Time Report Output].["Double Time"], [Employee Time Report Output].["Total Hours "], [lunch end]-[lunch start] AS tt
    FROM [Lunch Tracking] RIGHT JOIN [Employee Time Report Output] ON [Lunch Tracking].[Time at Lunch] = [Employee Time Report Output].Expr1;

    1000 ways to skin a cat, allways looking for another one...
    Use MDB format for sample post. If your issue is fixed, mark the thread solved.
    Click on the star below if this has helped.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-19-2011, 03:53 PM
  2. subtracting the value of fields in a form
    By petterros in forum Forms
    Replies: 0
    Last Post: 01-14-2011, 09:46 AM
  3. Comparing / Subtracting Tables
    By quigongrim in forum Queries
    Replies: 5
    Last Post: 09-10-2010, 05:59 PM
  4. Subtracting Fields
    By zakslaher in forum Access
    Replies: 15
    Last Post: 03-30-2010, 08:36 AM
  5. Subtracting Records
    By e13851mlee in forum Programming
    Replies: 1
    Last Post: 12-17-2009, 02: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
  •  
Tech Forums: Microsoft Office Forums