Results 1 to 2 of 2

vba > subtracting time

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

    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
    Anchorage, Alaska, USA
    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).
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

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