Change decimal value with code ?

pookie62

Registered User.
Local time
Today, 19:58
Joined
Jan 16, 2005
Messages
47
Hi all,
I'do a Transfertext to a commadelimited csv file.
Decimal values that are exported in this file, are rounded to two decimals and have a comma i.e.
Original value : 81,2222222
Value in csv : 81,22

Value needed for import in Mysql : 81.2222222

Is it possible to change this with VBA code ?

Thanks for supporting
 
Hi,
I don't know any way of changing it in VBA code using the Transfertext method. You can do it with the "CreateObject("Scripting.FileSystemObject").CreateTextFile" method, but it's more complicated and takes more time and system resources. So I'll porpose you an alternative solution:

I suppose you want to export a table, so you can create a Query with all the fields of this table and changing just the field you have troubles for a formula (if we are talking about a Query instead of a Table, still better, you can modify the field directly)

Naming the field you have troubles "THEFIELDIWANTWITHDECIMALS", replace in the Query the Table field for this formula:

THEFIELDIWANTWITHDECIMALS: Format(Replace([MYTABLE].[THEFIELDIWANTWITHDECIMALS];",";".");"@")

This Query will show a clone of your table (including same fieldnames) but for the data in that field, that would have been replaced for the same values changing commas for dots and in Text format.

Doing the same Transfertext sentence with this Query instead of your original Table would have to work...

Other tips: create an "Export specification" (select your table or query, choose "Export" in the File menu, select "save as" = "Text Files" and click on "advanced..."). Here you can create a specification changing, for instance, the character that marks the separation between fields in the CSV file (comma, semicolon...) or the character that qualifies a Text (inverted commas usually, it's better to select "anyone"). Once created you can save it with a specific name and use it in your Transfertext declaration.

I don't know if there are better or easier solutions, but this one at least works...
 
Thanks Jack,
Ill have a look to this solution..
 

Users who are viewing this thread

Back
Top Bottom