Results 1 to 6 of 6

Thread: [RESOLVED] Access XP Query - Preserve number format in calculated field

  1. #1

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Resolved [RESOLVED] Access XP Query - Preserve number format in calculated field

    In the image I've circled the formatting I'd like to retain in the calculated field. Can this be done?
    Name:  PreserveNumberFormatting.jpg
Views: 346
Size:  139.5 KB
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  2. #2

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: Access XP Query - Preserve number format in calculated field

    Either my question is poorly written or this forum area doesn't get much attention.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  3. #3
    Hyperactive Member
    Join Date
    Aug 2004
    Location
    Bloomingdale, IL USA
    Posts
    284

    Re: Access XP Query - Preserve number format in calculated field

    I would guess poorly written.... I'm not really sure what exactly you are asking. What calculated field are you referring too and what is the calculation you are using?

  4. #4

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: Access XP Query - Preserve number format in calculated field

    I'm not even sure if 'calculated field' is an appropriate term. In the image, the field named 'Station' is a combination of fields 'CS_NUM', 'CS_MP', 'PLUS_MINUS and 'LOC_CD'. The issue is that values from field 'CS_MP', such as '0.000', end up as '0' in the combined field. I'd prefer they retain the '0.000' format. Also note that field 'CS_MP' is number formatted properly in the database to display 3 decimal places. I believe the problem is related to converting it to a string and technically '0.000' is ZERO.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  5. #5
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Access XP Query - Preserve number format in calculated field

    Unfortunately your picture doesn't show for me so I'm not sure if this answer is apropriate but it sounds to me like you're looking for the Format command in Access.

    Your calculated field will have an underlying formula. You simply need to wrap the bit of the formula that's converting CS_MP to a string in a format with the apropriate format mask.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  6. #6

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: Access XP Query - Preserve number format in calculated field

    Wish I would've noticed this two weeks ago. Oh well, your suggestions was right on target and solved my problem.

    Referencing the image above, if anyone can see it, I changed the calculation of the field to:

    Station: [CS_NUM] & " " & Format([CS_MP],"#0.000") & [PLUS_MINUS] & [LOC_CD]

    And produced, i.e., "54011 0.000+R" instead of "54011 0+R".

    Thank you!
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

Posting Permissions

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



Click Here to Expand Forum to Full Width