Results 1 to 2 of 2
  1. #1
    BobW2961 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2016
    Posts
    16

    Report Text Box is rounding


    I have a field called "Autotime". It is an integer field and contains the number of seconds a machine was in automode.
    If a machine was in auto for 28798 seconds, then I want my report to display 7hrs 59min 58secs.

    I create three texts boxes on my report. Hrs, Mins, Secs.
    The control source for Hrs is =Format([Autotime]/3600,0)
    This give me the result I want as far as it has no numbers after the decimal, however the result is 8 instead of 7.
    How do I stop a text box from rounding up? Only thing I can find is how to stop a field from rounding up.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    run FillTextBoxTime() to fill in each textbox from the seconds given.


    Code:
    Public Sub FillTextBoxTime()
    Dim iSecs
    
    iSecs = 28798    'aka [Autotime]
    
    'txtDays = getTimePart(iSecs, "D")
    txtHrs = getTimePart(iSecs, "H")
    txtMins = getTimePart(iSecs, "N")
    txtSecs = getTimePart(iSecs, "S")
    End Sub
    
    
    Public Function getTimePart(pvSecs, ByVal pvUoM)
    Dim vTxt, sUnit
    Dim iNum As Long
    Const kDAY = 86400
    Const kSECpYR = 31536000
    
    
    Select Case pvUoM
       Case "D"
            iNum = pvSecs \ 86400
       Case "H"
            iNum = pvSecs \ 3600
       Case "N"
            iNum = pvSecs \ 60
       Case "S"
          iNum = pvSecs
    End Select
    
    
    
    
    Select Case pvUoM
           Case "D"      'day
              sUnit = "day"
              If iNum > 0 Then
                   vTxt = vTxt & iNum & " " & sUnit
                   pvSecs = pvSecs - (iNum * kDAY)
              End If
              getTimePart = iNum & " day"
           
           Case "H"       'hrs
              sUnit = "hr"
              If iNum > 23 Then iNum = 23
              If iNum > 0 Then
                   vTxt = vTxt & iNum & " " & sUnit
                   pvSecs = pvSecs - (iNum * 3600)
              End If
              getTimePart = iNum & " hr"
           
           Case "N"         'min
              sUnit = "min"
              If iNum > 0 Then
                   vTxt = vTxt & iNum & " min "
                   pvSecs = pvSecs - (iNum * 60)
              End If
              getTimePart = iNum & " min"
           
           Case Else
              
              sUnit = " secs"
              getTimePart = iNum & " sec"
        End Select
    Exit Function
    
    
    End Function

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

Similar Threads

  1. Replies: 1
    Last Post: 06-07-2018, 08:05 AM
  2. Rounding off a number in a text box
    By angie in forum Forms
    Replies: 4
    Last Post: 03-13-2018, 05:19 PM
  3. Rounding down in a report field
    By drnld in forum Access
    Replies: 4
    Last Post: 05-27-2014, 05:42 PM
  4. Replies: 12
    Last Post: 10-22-2012, 06:11 AM
  5. Stop text box from rounding decimals
    By Deutz in forum Access
    Replies: 1
    Last Post: 02-17-2011, 07:32 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
  •  
Other Forums: Microsoft Office Forums