help with formatting and exporting data

W

walark

I have a table that has a number of decimal fields. I need to export the
table to a text file and have the decimal fields right justified. They keep
coming out left justified. How do I change the justification? I'm trying to
use a spec file, but I can't seem to get it right.
 
K

Klatuu

Since everything in a text file is text, everything is left justified. A
work around is to add spaces to the beginning of the value. You have to
decide how wide you want the column to be so you know how many spaces to add
depending on the length of the number:
Let's say you want the width of the column to be 14 characters.

In the query builder
SomeNumber: Format([FieldName],Space(14-Len(Format([FieldName],"0.00"))) &
"0.00")

In SQL:
SELECT Format([FieldName],Space(14-Len(Format([FieldName],"0.00"))) &
"0.00") As SomeNumber
 

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