Results 1 to 6 of 6
  1. #1
    lwilt is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    7

    Converting a Number to Decimal

    I'm trying to convert a cost field from number to having a decimal place. So I want 1 to be 1.00 and 5.4 to be 5.40. If I go into the tables design view and change the field size to decimal and select how many decimal places it won't change anything the way I want. I tried using CDec function but it said invalid format.

    Is there a function that will do this for me? thank you

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What is the current Field Type? Single, Double, Currency...

  3. #3
    lwilt is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    7
    It was double when I tried using the convert function CDec and then I changed the field type to decimal and selected 2 decimal places and 1 stayed at 1 instead of becoming 1.00. I also tried the function again at that point and it didn't work.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    As you know, trailing zeros in a numeric field are not significant. Displaying 2 decimals is simply a display option and can be set in the control that displays the value.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If you change the properties for the field in the TABLE from Double to Decimal, you also should change other properties:

    FORMAT : Standard (<< how the data looks in the table)
    SCALE : 2
    DECIMALS : 2

    Warning: When you change these, you could lose some data.

    The format property (in the table) controls how the data looks when you view the table. Might look different in a control on a form/report.

  6. #6
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    1) You're safer using Currency data type, if you care about accuracy and retaining exact numbers. Decimal doesn't guarantee results, accounting-wise.
    2) If you're converting a field on your database, you should add the new field, monkey with it using update queries until you have the results you want, then delete the old field and rename the new one.

    Do that in a junk copy of your database, and back up the prod one both before and after you port over the changed format.

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

Similar Threads

  1. Converting text to 2 decimal places
    By lwilt in forum Access
    Replies: 1
    Last Post: 09-13-2013, 09:58 AM
  2. Replies: 5
    Last Post: 07-18-2013, 01:43 PM
  3. Replies: 0
    Last Post: 10-22-2012, 02:45 PM
  4. Converting Hexadecimal to decimal
    By darvis_aurian in forum Access
    Replies: 5
    Last Post: 04-05-2012, 01:20 PM
  5. Converting HH:MM to decimal
    By katrinanyc926 in forum Queries
    Replies: 5
    Last Post: 08-13-2010, 02:39 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