• Rounding

    • This topic has 9 replies, 4 voices, and was last updated 24 years ago.
    Author
    Topic
    #354234

    I’m using access 97 and most of my number fields are for Italian Lira such as 55,456,789 I would like to round up to 55,457 but have had no luck yet, any help would be much appreciatd thanks in advance
    braddy60

    Viewing 0 reply threads
    Author
    Replies
    • #520085

      Try

      (Lira+500)1000

      Note that is the integer division operator (i.e. it does division and throws away the fractional part).

      • #520119

        Hi Douglas thanks for your quick response to my problem,If I tell you I am very new to access you will understand when I say I had difficulty in applying the format you posted for me because when I enter it Access puts in quote marks and turns it to text, sorry if I sound a bit stupid

        thanks again braddy60

        • #520226

          Are you trying to populate a field or a variable? Are you working with values from a field or a variable? If you have a field called Lira, with a value of 55,456,789 and you want to assign the value rounded to the nearest 1000s to a variable, you would do it like this:

            Dim lngLira As Long
            lngLira = ([Lira]+500)1000

          The 500 you’re adding to the value in [Lira] is to force a round up. Does that make it clearer?

        • #520247

          What Douglas gave you is not a format, it is a formula to calculate the rounded value. You can not use formats to round field values. The foumula could go in a number of places, depending on exactly how you want thing to work. It could go in the query or the beforeupdate event procedure when the value is put into the field in the table. It could go in the query that retrieves the value from the table, or it could go into code that puts the value into control on a form or report.

          • #520255

            Thanks for your help
            You are on the right track to understand what I am trying to do but as yet I have had no succes, I tried to use the formula in query but I could not get it to work.

            Thanks braddy60

            • #520259

              This works for me:

            • #520276

              Hi Legare thanks for trying to help me with my problem, as a layman I probably misled you
              I have attached a Jpeg the field I’m trying to formulate the field in question is marked in red
              and the formula that creates this field is =[Embedded43].[Form]![lira net price]

              Thanks again

            • #520279

              Try changing that to:

              =([Embedded43].[Form]![lira net price]+500)1000
              
            • #520281

              Hi Legare

              You’re a genius, it worked fine thank’s a lot

              braddy60

    Viewing 0 reply threads
    Reply To: Rounding

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: