Table Field Rounding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BurtonBach
    New Member
    • Oct 2006
    • 58

    Table Field Rounding

    Do number fields automatically round to whole number? Is there a way to stop it from rounding? I have tried setting the decimal places to 2 and it still rounds.
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Originally posted by BurtonBach
    Do number fields automatically round to whole number? Is there a way to stop it from rounding? I have tried setting the decimal places to 2 and it still rounds.
    Setting a field to a number is only the start of the process you must also set the Format. It sounds as if your numbers are formatted as Integers change to double and this should solve your problem.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      Yes, The default FieldSize of a number variable is Long Integer.
      As Mary says, you need to set this property to Double to enable it to store decimal places.

      Comment

      • southoz
        New Member
        • Sep 2006
        • 24

        #4
        Good ay ,
        I had a simular problem an after a few hours of fustration i just chanced the field to
        a textbox , then on calculations I just use temp2 = Val(Me!quantity )
        been working fine ever since and saves all the hassles related to access numeric formats

        southoz

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32633

          #5
          Originally posted by SouthOz
          Good ay ,
          I had a simular problem an after a few hours of fustration i just chanced the field to
          a textbox , then on calculations I just use temp2 = Val(Me!quantity )
          been working fine ever since and saves all the hassles related to access numeric formats
          While that would work SouthOz, I wouldn't recommend it.
          You're really much better off understanding what the problem really is about.
          The field types can be your friends if you understand them.

          Comment

          • PEB
            Recognized Expert Top Contributor
            • Aug 2006
            • 1418

            #6
            Hi

            Using the val funcion with decimals is very dangerous...

            Coz If your decimal separator is a comma, so the decimal part of your number is rounded....

            It works good only with the dot :)

            Originally posted by southoz
            Good ay ,
            I had a simular problem an after a few hours of fustration i just chanced the field to
            a textbox , then on calculations I just use temp2 = Val(Me!quantity )
            been working fine ever since and saves all the hassles related to access numeric formats

            southoz

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32633

              #7
              We don't have that problem over here PEB ;).
              What about the C functions (CInt; CDbl; CLng; etc)? Do they handle ',' & '.' properly?

              Comment

              • PEB
                Recognized Expert Top Contributor
                • Aug 2006
                • 1418

                #8
                NeoPa change your regional settings to use the comma as decimal separator and try the val()

                and tell me about the results

                Easy way to do the test:

                ?val("123.32")
                123,32
                ?val("123,32")
                123

                What is your conclusion about val()?

                ;)

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32633

                  #9
                  I mean - we don't have the problem because our regional settings AREN'T like yours on the continent.
                  I wasn't arguing with you - just a little joke ;).

                  I wouldn't argue with someone who has over 1,000 posts on the Leader Board (Congratulation s).

                  -Adrian.

                  Comment

                  • PEB
                    Recognized Expert Top Contributor
                    • Aug 2006
                    • 1418

                    #10
                    In fact the strange history when I've detecting this particularity of Val...

                    In all computers where I'm working my regional Settings are to use the point as decimal separator...

                    One time from a company that used my accountancy program called me and told me for error in the calculations...

                    Till i understand what was the reason for this error...

                    JUST THE VAL() That is doing wrong ROUND

                    SO FOR EVERYBODY WHO CHANGES THE REGIONAL SETTINGS! TAKE CARE ABOUT THE FUNCTION VAL()

                    :)

                    Comment

                    Working...