Results 1 to 9 of 9
  1. #1
    AMRI YULIANDI is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    8

    need help number rounddown


    need some help guys, im newbie..

    here the example.

    A = b * c then we get value 65.5, then in my table is 66, how can i make it stay at 65? not roundup to 66?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,815
    AFAIK to prevent actual rounding before storing in a table you'd have to use a query or function to coerce the value to what you want. The trick with Access tables is that often, what you see isn't what's really there. Dates would be a prime example - they are actually a form of decimal number. Right now the date and time is 44658.0091782407 .

    If you don't round down with a function or query that uses one because you're actually typing in your table fields (which you should not) I believe you would have to set the field to decimal data type and set the Scale and Decimal Places properties to 0. More than likely, the table will contain 5.5 but you will only see 5, which probably would suit your purpose.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    AMRI YULIANDI is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    8
    can you give the query example sir? thank you

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,989
    Quote Originally Posted by AMRI YULIANDI View Post
    need some help guys, im newbie..

    here the example.

    A = b * c then we get value 65.5, then in my table is 66, how can i make it stay at 65? not roundup to 66?
    For that 'simple example' you could use the Int() function?

    Code:
    ? int(65.5)
     65
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    AMRI YULIANDI is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    8
    yeah already know using int but problem if it negative number, anyway thank you guys

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,989
    Quote Originally Posted by AMRI YULIANDI View Post
    yeah already know using int but problem if it negative number, anyway thank you guys
    So round down means round up when negative?

    Then combine it with ABS() ?
    Write your own function to do whatever you want it to do.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,815
    "or use a query that uses one" meant uses a function. You need to say more about how you're inputting the data if you need more help. Int won't work in a calculated form field unless that field is not bound.. Int should work in a query:

    UPDATE Sheet1 SET Sheet1.CountY = Int(5.5) WHERE (([ID]=3));

    or in code.

    see http://allenbrowne.com/round.html
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,989
    Quote Originally Posted by Micron View Post
    "or use a query that uses one" meant uses a function. You need to say more about how you're inputting the data if you need more help. Int won't work in a calculated form field unless that field is not bound.. Int should work in a query:

    UPDATE Sheet1 SET Sheet1.CountY = Int(5.5) WHERE (([ID]=3));

    or in code.

    see http://allenbrowne.com/round.html
    I was thinking along the lines of
    Code:
    tt=6.5
    ? iif(tt<0,INT(ABS(tt))*-1,int(tt))
    -6 
    tt=6.5
    ? iif(tt<0,INT(ABS(tt))*-1,int(tt))
     6
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,815
    Quote Originally Posted by Welshgasman View Post
    I was thinking along the lines of
    Code:
    tt=6.5
    ? iif(tt<0,INT(ABS(tt))*-1,int(tt))
    -6 
    tt=6.5
    ? iif(tt<0,INT(ABS(tt))*-1,int(tt))
     6
    Perhaps, but if this is about a form, a calculated field cannot be bound to anything so that may be an issue. That's why I said
    You need to say more about how you're inputting the data if you need more help.
    The OP is about as skimpy as they get. That sql seemed to work for me in a test so I expect a function would also. Until sufficient info is provided, I don't think I have anything else to add.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 10
    Last Post: 08-02-2021, 08:17 AM
  2. Replies: 10
    Last Post: 04-01-2018, 07:45 AM
  3. Replies: 5
    Last Post: 11-30-2014, 12:46 PM
  4. Replies: 0
    Last Post: 10-22-2012, 02:45 PM
  5. Replies: 6
    Last Post: 07-25-2011, 01:54 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