Access Export Question

L

leejinhoo

Hi All,

I have a quick question about Access. I know in Access you can export
the database into txt file (and choose which fields go to which
space). However, the numbers in the txt file are all "align left".
Would you please tell me how to do it in "align right"? Many Thanks!


e.g.
The txt file is like this:
A____1___34567.10___222.10
A____2___123.10_____45677.10

This is what I want:
A____1____34567.10_____222.10
A____2______123.10___45677.10
 
J

Jerry Whittle

I'm assuing that you are exporting as fixed width. It can be a pain to do.

For the number fields you can do something like below in a query then export
the query. Make sure that the number, like 9 below, is large enough to hold
the largest number. With a query you can chose the fields and their order.

AmtPadded: String(9-Len([Amt])," ") & [Amt]

However Access has a bad habit of looking at the original field size and
cutting things off there. In that case you need to go to the Advanced button
during the Export wizard and make the width larger for those fields. If the
number is in the middle of the query, you'll need to do the math and make all
the columns fit properly.
 
P

Pete D.

Not possible, text files don't have alignment. Many editors fake this
feature with tabs but when saved as txt file the tabs are padded with space
character. You could duplicate this feature with VBA padding field lengths
but why would you. Use comma separated values and then you can open it in
excel, access restored to cells or fields. I am curious as to how it aligns
like your showing as columns don't usually align like that unless you are
already padding them with spaces.

This would be more normal
A 1 123 12321
B 2 12345 1233
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top