Results 1 to 7 of 7
  1. #1
    SealM is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Posts
    40

    Update Query that converts a Number into it's 1/100th

    Hi everyone, this may be my silliest question yet, but nonetheless, I cannot figure this one out:

    In the table RAW, I have a field "cost_of_call". This is a number, in cents, and I want to convert it to it's number in dollars. In Excel, this would be an easy calculation, but in Access, when I try to perform it, it returns the average whole number when I try to multiply by 0.01.

    here are my example numbers:
    23


    55
    506
    3025

    I need an UPDATE query that will turn these numbers into:
    0.23
    0.55
    5.06
    30.25

    All I get when I run this query: UPDATE Raw SET Raw.cost_of_call = Format([cost_of_call]*0.01,"Fixed");
    0
    1
    5
    30

    Can someone please tell me what the query needs to be to return values with 2 decimal points? Thanks!
    Mike

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    I doubt it's the query. What's the data type of that field in the table?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    SealM is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Posts
    40
    long integer, format is blank, decimal is 'auto' (although I changed this to two and re-ran the query and it still gives the approximate nearest whole number). Everything else is blank, not requiried, non-indexed...

    Now that I look at this, I can go to the table in datasheet view, and manually change 11 to 11.1, and as soon as I tab off of it, it goes right back to 11. So these 'long integer' fields act like they cannot hold a decimal value.

  4. #4
    SealM is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Posts
    40
    Bah.. I change the field type to "double" and it holds a decimal just fine. But, how can I either create a "double" field to hold this data or convert an existing field using a query? This field is created when data is imported into a table, and it defaults to a long integer field. Is there a way to make a long integer field into a double field using an update query?

    And thanks for helping me, btw! =)

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Integer fields don't just act like they cannot hold a decimal value...they can't.

    You can use your same expression in a SELECT query to display the value properly. If you want to actually change what's in the table, you'll need to change the data type or add a new field. Either can be done with a DDL query (ALTER TABLE...)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    SealM is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Posts
    40
    Okay, since I'm a noob still, I had to look it up. This works just fine to change my field named "cost_of_call" from long integer to double:

    ALTER TABLE Raw
    alter column cost_of_call double;

    I only post this for posterity, and to help future instances of myself or those like me with this solution. Thanks!!

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Happy to help! If it makes you feel any better, I would have had to look it up too, to get the syntax exactly right.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Access Converts Date to String....Why?
    By rgutshall in forum Forms
    Replies: 11
    Last Post: 01-25-2013, 09:13 AM
  2. Replies: 3
    Last Post: 01-09-2013, 10:13 AM
  3. Replies: 2
    Last Post: 05-30-2012, 10:38 AM
  4. Update number field
    By TinaCa in forum Queries
    Replies: 3
    Last Post: 05-09-2012, 09:14 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