Results 1 to 5 of 5
  1. #1
    NightWalker's Avatar
    NightWalker is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2016
    Location
    Midwest USA
    Posts
    253

    Adding time trouble

    I am trying to add 8.5 hour to a time in a txtbox that is bound to a form.


    why does this code not work?

    Code:
    txtShiftEnd = DateAdd("h", 8, [TimeIN]) & DateAdd("n", 30, [TimeIN])

    i get a really crazy answer with the second one like it is putting 2 answers in the same text box. so i tried this to add the two together. and it didnt work.

    Code:
    txtShiftEnd = DateAdd(sum("h", 8, [TimeIN]) & ("n", 30, [TimeIN]))

    I figured it out by using this code but i am wondering why it didnt allow the first one to work

    Code:
    txtShiftEnd = DateAdd("n", 510, [TimeIN])
    Thank you for your instruction and clarification


    Walker

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    it the time in the txtbox is in hours, then:
    txtBox + 8

    it you want the TIMEOUT :
    txtTimeOut = DateAdd("h",8.5,TIMEIN)

  3. #3
    NightWalker's Avatar
    NightWalker is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2016
    Location
    Midwest USA
    Posts
    253
    txtTimeOut = DateAdd("h",8.5,TIMEIN)
    I tried that and it only gave me an even number. the time in the TimeIN txtbox was 8:00 and the answer it gave me was 16:00 even though i had 8.5 to add to it

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    then your field is formatted wrong (integer or long) , you need to format is as single to see decimals.

  5. #5
    NightWalker's Avatar
    NightWalker is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2016
    Location
    Midwest USA
    Posts
    253
    <------Palms forehead and saya "oh yeah......DUH!"

    Thanks ranman

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

Similar Threads

  1. Trouble Adding employees to a form
    By Lou_Reed in forum Access
    Replies: 26
    Last Post: 06-09-2017, 01:29 PM
  2. Replies: 12
    Last Post: 07-19-2015, 05:21 PM
  3. Replies: 1
    Last Post: 03-13-2014, 07:23 PM
  4. Replies: 8
    Last Post: 12-12-2013, 03:54 PM
  5. Trouble adding data with forms
    By chuck130 in forum Forms
    Replies: 3
    Last Post: 09-02-2010, 09:57 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