Results 1 to 14 of 14
  1. #1
    kestefon is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    108

    Text Export Has Too Many Trailing Zeroes (e.g. 1.00000)

    Hi Everyone,



    For some reason, whenever I export a query to text, every number has trailing zeroes after it. This happens with any number, even integers.

    Examples:
    1.000000000
    5.250000000
    0.600000000

    Nine decimal places would be fine if the number extended that far, but I want to get rid of the trailing zeros so that 1.0000000 becomes 1, and 5.2500000 becomes 5.25, etc.

    Now, I have noticed that a setting in the Control Panel > Region and Language > Formats Tab > Additional Settings > Numbers Tab controls the numbers of decimal places, but if I adjust it to two or zero it just cuts the data off at that point.

    Any ideas?

    Click image for larger version. 

Name:	FormatScreenshot.png 
Views:	11 
Size:	68.6 KB 
ID:	15058

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Hoe exactly are you exporting it? If you export it without formatting, it should drop all trailing zeroes (provided that the field in question is a Numeric datatype and not String/Text).

  3. #3
    kestefon is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    108
    I'm exporting it as a pipe-delimited text file. I don't mark the "export with formatting" box.

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Do you have an Export Specification you are using?
    Are all these underlying number fields formatted as numeric data types?
    In the query, is anything (or any function) being applied to these fields?

  5. #5
    kestefon is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    108
    No export specifcations that I know of. I'm just right-clicking the query, clicking Export > Text File, and then following the steps to make a pipe-delimited file. Also, the fields are indeed numeric, and there are no functions or calculations being applied to the fields.

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    What program are you using to view the Text file?

  7. #7
    kestefon is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    108
    Notepad, although it looks the same in Notepad++. Are you guys saying that you don't have this type of issue when you export to text? I was starting to think it was like this for everyone using Access.

  8. #8
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    So I did some testing, and I guess I never realized it did that. Formatting to two decimal places was always sufficient for me, I guess.

    However, if you want to get rid of the trailing zeroes so that different entries may have a different number of decimal places, one way is to convert the number to a string in your query using the Cstr function, like this:
    MyField2: Cstr([MyField])

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    you might also be able to do it with

    Myfield2: format([myfield], "##.##")

    or something similar

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The only way I was able to export the trailing zeros was to use formating at the table level. Perhaps formatting at a report level or your query will provide the results desired.

    Click image for larger version. 

Name:	DoubleFormated.jpg 
Views:	8 
Size:	27.9 KB 
ID:	15065

  11. #11
    kestefon is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    108
    Awesome, thanks... I'll try some of these options out.

  12. #12
    kestefon is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    108
    Using CStr in the query worked. Quick question regarding Access formatting--will Access ever round data during SQL query if you don't specify anything? For instance, if a record is 5.36543453, I'll want the query result to include as much of that as possible. That seems to be the case by default, but I just want to confirm.

  13. #13
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    correct, when doing a mathematical function on a field it uses whatever is there, not just whatever's visible in the table view, so if you have 10 decimal places but the formatting only allows 2 decimal places it's still using decimal places 3 through 10.

  14. #14
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I believe if you get a value from a formatted control it could possibly be truncated. If your query is getting the value from the table that is one thing but if your query references a control in a form that is another thing. I would definitely want to test the scenario if the source is anywhere other than the table.

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

Similar Threads

  1. Join Types and inputting zeroes
    By athyeh in forum Queries
    Replies: 4
    Last Post: 11-22-2013, 11:58 AM
  2. Removing Trailing Numbers
    By swagger18 in forum Programming
    Replies: 3
    Last Post: 01-28-2011, 02:39 AM
  3. Trailing Spaces workaround
    By shexe in forum Queries
    Replies: 23
    Last Post: 09-21-2010, 04:28 AM
  4. Checking for trailing letter
    By jgelpi16 in forum Queries
    Replies: 2
    Last Post: 03-23-2010, 09:27 AM
  5. Leading Zeroes
    By FREEEEEEDOM in forum Access
    Replies: 2
    Last Post: 04-06-2009, 10:23 AM

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