Access Export to Txt Decimals

jarett

Board Regular
Joined
Apr 12, 2021
Messages
165
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Setting up this export from a query, in the query the number looks like a whole number but when the data is exported it adds a decimal and 2 zeros. This value is coming from a predefined table that I cannot change the format. Should I be able to change the properties within the query to get the correct result in the txt file? This is my query result and the text file it exports. The other number exports correctly, which I am assuming it is a different format because it is left justified.
Untitled.png

Untitled1.png
 

Attachments

  • Untitled.png
    Untitled.png
    9.1 KB · Views: 4
  • 1620831435635.png
    1620831435635.png
    12.1 KB · Views: 5

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
It may depend on exactly how you are exporting it (manually or by macro or VBA code)?
Can you list out your exact steps?

I would recommend trying to format that field in the query for zero decimals, and try exporting again.
If that works, you are all set. If not, you may need to convert that field to Text in your query with a function before exporting.
 
Upvote 0
It may depend on exactly how you are exporting it (manually or by macro or VBA code)?
Can you list out your exact steps?

I would recommend trying to format that field in the query for zero decimals, and try exporting again.
If that works, you are all set. If not, you may need to convert that field to Text in your query with a function before exporting.
Yes I am exporting through a macro. I set up the export specification with the following specs; comma delimited with text qualifier=none. In the wizard it looks correct with no decimal. I went to the query and right clicked the field, properties and selected 0 decimal places, format general number, should I try something else? This is the formula I have to use to get the value if it helps explain,Qty Ordered: IIf(IsNull([PO068_MXPPOTierDistribution]![QuantityOrdered]),([po_detail1]![QuantityOrdered]),[PO068_MXPPOTierDistribution]![QuantityOrdered])
 
Upvote 0
Try wrapping your formula in the "Str" function, which should convert it to Text, in which case it should then export exactly as it appears in the query, i.e.
Rich (BB code):
Qty Ordered: Str(IIf(IsNull([PO068_MXPPOTierDistribution]![QuantityOrdered]),([po_detail1]![QuantityOrdered]),[PO068_MXPPOTierDistribution]![QuantityOrdered]))

See: MS Access: Str Function

Not sure, but it might make you change your Export Specification after that, as it is no longer a numeric field.
 
Upvote 0
Solution
Try wrapping your formula in the "Str" function, which should convert it to Text, in which case it should then export exactly as it appears in the query, i.e.
Rich (BB code):
Qty Ordered: Str(IIf(IsNull([PO068_MXPPOTierDistribution]![QuantityOrdered]),([po_detail1]![QuantityOrdered]),[PO068_MXPPOTierDistribution]![QuantityOrdered]))

See: MS Access: Str Function

Not sure, but it might make you change your Export Specification after that, as it is no longer a numeric field.
Worked awesome thanks
 
Upvote 0
You are welcome.

Typically, if you have control over the data Table, you choose a number option that does not allow decimals, and I think that would take care of it organically.
But since you don't, we need to address it in the Query, and there are a few "tricks" we can use.
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,825
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top