Exporting dollar amounts to a .csv file drops cents (.00)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lac55
    New Member
    • Apr 2012
    • 12

    Exporting dollar amounts to a .csv file drops cents (.00)

    I have a query that contains several dollar amount columns. I have used the Format function (Format(fieldna me,"Standard") in order to retain the cents. If the amount contains cents, it exports correctly. But if there are no cents (.00), the export drops the .00. I have also used Cstr(Format(fie ldname,"Standar d")) to no avail. My query results look perfect. The .csv results do not.

    I have been having the same problem with exporting date fields where I have stripped off the time portion. The query looks great, but in the .csv file, 0:00 has been appended to every date field.

    I have Access 2007 SP2. I am willing to try any suggestions.

    Thank you in advance.
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Try to use the second parameter of the format() with "Fixed" or use a mask with 0.00

    Comment

    • Mihail
      Contributor
      • Apr 2011
      • 759

      #3
      Also take a look here !

      Comment

      • lac55
        New Member
        • Apr 2012
        • 12

        #4
        I will just keep trying different things. I have tried all suggestions and the query results look great. It is during the export that I have trouble. And, the export works just fine on some of my amount columns, but not on all. Thanks for all the suggestions.

        Comment

        • lac55
          New Member
          • Apr 2012
          • 12

          #5
          I did just now have some success with this last column by using Total Fees: Format([total_fees],"Currency"). I do end up with the $ sign, but I don't think that will be a problem for my end user. I can't explain why the "currency" parameter works and Total Fees: Format([total_fees],"Standard") and Total Fees: Format([total_fees],"Fixed") don't, but at this point, after 3 days, I'm just happy to be able to give my end user the cents on all amount fields.

          BTW, when I try Format(currency field, "0.00"), the "0.00" automatically changes to "Fixed". When I enter "###,##0.00 ", Access automatically changes it to "Standard". Is there by any chance a way to use "Currency" and suppress the $ sign? I'm guessing the answer to that would be to use "Standard" or "Fixed", but those are the 2 settings that don't give me the cents portion on this one column.

          I even had the database adminstrator check to see if this column in the source ODBC database was set up like all the other amount columns that export correctly. The answer was yes.

          Thanks again to everyone for all your suggestions!
          Last edited by lac55; Apr 18 '12, 03:21 PM. Reason: typo

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32653

            #6
            At which point does this change occur?

            I have a saved query with a Format(,'#,##0. 00') expression in it and it always loads with that same string parameter exactly as I saved it. I'm using Access 2003 on XP. What about you?

            Comment

            • lac55
              New Member
              • Apr 2012
              • 12

              #7
              Access 2007 . . . newer isn't always better. As soon as I type "#,##0.00" and hit enter, it changes.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32653

                #8
                Office 2007 is better than diddly.

                Just as a last test try using the SQL standard quotes (') instead of the ones Access uses ("). I doubt it will fool it but you may as well try, and it's probably better practice anyway ;-)

                Comment

                • lac55
                  New Member
                  • Apr 2012
                  • 12

                  #9
                  I'll give that a try. But just to recap. Everything I try looks great in the query results. It is only after I export the query to a .csv file that I have issues. The query looks great . . . this one column in the .csv file doesn't.

                  I suspect it has more to do with the TransferText macro action and the Export function from the ribbon than with the actual Access functions. When I go through the Export wizard from the ribbon and see what the results will look like, the cents in that one amount column are not displayed if the amount is even dollars.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32653

                    #10
                    I'm confused this seems to be a direct contradiction of what you said in post #7.

                    Is the query ever saved without the string parameter replaced by the appropriate text version ("Standard; Fixed; etc)?

                    Comment

                    • lac55
                      New Member
                      • Apr 2012
                      • 12

                      #11
                      No, the query never saves without replacing the "0.00" with "Fixed" or "###,##0.00 " with "Standard".

                      I'm not sure what Post #7 is. I have only posted 2 questions on this site and admit I know very little about the process. Does #7 means the 7th item in the above stream? If so, what I meant to say was when I am typing in the field inside my query in Design View and type "0.00" as part of the Format function, as soon as I hit enter, Access changes the "0.00" to "Fixed".

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32653

                        #12
                        Post #7 refers to the 7th post in the thread. Each post has its ordinal number included immediately after the timestamp is displayed (EG. 18 minutes ago #11) currently by your latest post. It can be found below the post contents. It's useful as a reference, but can change if earlier posts get deleted for any reason (which they do).

                        If your QueryDefs are always changed to reflect "Fixed" or "Standard" then the behaviour you describe is entirely unsurprising. These will work fine in most cases, but they rely on the number of DP being determined for you. This is not good when you require that they're set explicitly. Does that all make sense?

                        Comment

                        • lac55
                          New Member
                          • Apr 2012
                          • 12

                          #13
                          Ahhh . . . I see the post # now. Thanks for the explanation. Do you happen to know if there is a way in Access 2007 to keep the QueryDefs from always changing to "Fixed" or "Standard". I would like to have more control over that.

                          Just an added note. I opened my query in which "#,##0.00" gets automatically changed to "Standard" in Design view. Then I switched to SQL view and changed the parameter back to "#,##0.00" and saved it. It retained the "#,##0.00" in SQL view, but in Design view, it still shows "Standard".

                          It's odd that if I use the "Currency" parameter, I get my desired result of have cents included with whole dollar amount fields. But "Standard" and "Fixed" don't. There just seems to be no rhyme or reason for this one column.

                          Oh, and one other interesting tidbit. When I go through the Export wizard, I can see the amount field with cents. But when I click Finish and my .cvs file gets created, the cents are not in the file (again, for this one field).

                          Comment

                          • NeoPa
                            Recognized Expert Moderator MVP
                            • Oct 2006
                            • 32653

                            #14
                            Originally posted by Lac55
                            Lac55:
                            Do you happen to know if there is a way in Access 2007 to keep the QueryDefs from always changing to "Fixed" or "Standard". I would like to have more control over that.
                            I still use 2003 myself mainly, but when I move you can be sure that it will be to 2010. i'm more than happy to bypass Office 2007 and Windows Vista ;-) In answer though, I know of no way to force that other than the suggestions I made earlier which I suspect had no effect.

                            Originally posted by Lac55
                            Lac55:
                            It retained the "#,##0.00" in SQL view, but in Design view, it still shows "Standard".
                            Did you check the SQL view again after saving it in Design View? It's a forlorn hope, I know, but worth checking maybe.

                            Comment

                            • lac55
                              New Member
                              • Apr 2012
                              • 12

                              #15
                              Yeah, I think Access 2007 has issues with the Export function from the ribbon and the TransferText action in a macro. I don't have any trouble in the queries getting the results I want. It's only when exporting to a .cvs file that I have trouble . . . and it isn't on every field. Most are working great.

                              And yes, I checked the SQL view after saving in Design view. The "#,##0.00" is stil in SQL view. But it didn't affect my results. I had hope there for a minute, especially after seeing the cents in the wizard. But, alas, no cents in the .csv file.

                              Comment

                              Working...