Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    146
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Decimal Places (2000 SR-1)

    Hi,

    While running some VB code on a table, I've started to get this message on decimal fields: Scaling of decimal value resulted in data truncation. Strange thing is, this code ran OK when it was run from a button on a form that displayed each record of the table. When I adapted the code to run on all records of the table--using the RecordSet object--this problem came up. That is, the code works with the Worked variable, but it doesn't work with the rs!Worked variable. I've tried all kinds of combinations of the Precision, Scale, and Decimal Places settings, but have had no luck.

    Thanks,
    Bob

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Decimal Places (2000 SR-1)

    I'm afraid we can't help very much with this unless we see the code that is giving the message. Decimal (currency) fields in Access do have a finite value range, so if you are doing arithmetic with them, you can get situations where the data gets truncated. And direct recordset manipulation may occur where internal VBA variables won't because they are not actually saved internally as a decimal value.
    Wendell

  3. #3
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    146
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Decimal Places (2000 SR-1)

    Here's what works when generated from a form button on one record:

    PercentProduction = (AvailIncentiveTime - ApprovedDownTime) / AvailIncentiveTime

    Here's what doesn't work when generated from a form button on all the records in a table:

    rs!PercentProduction = (rs!AvailIncentiveTime - rs!ApprovedDownTime) / rs!AvailIncentiveTime

    The PercentProduction decimal variable crashes the code. I tried changing it to an integer as a test, and the code crashed on a later decimal variable.

    Thanks,
    Bob

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Decimal Places (2000 SR-1)

    Although the Decimal data type is allowed, it is not a native Access data type. Problems with it have been reported before. I recommend changing the data type to Double or Single.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Decimal Places (2000 SR-1)

    Unless you need floating point data types, use a Currency type, not a Decimal. That gives you 4 decimal places, without any floating point creep.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •