Padding Fields with spaces

N

Natalie

How can I pad a field with spaces if it’s a character, numeric or date?

For example Customer Name (14) Telephone Number (20) FeeAmt (15)
“Jones “ “ 8772774000“ “ 15.41â€
What should I do in my query to tell it to pad each field with spaces if the
value is not the size of the field?
 
J

John W. Vinson

How can I pad a field with spaces if it’s a character, numeric or date?

For example Customer Name (14) Telephone Number (20) FeeAmt (15)
“Jones “ “ 8772774000“ “ 15.41”
What should I do in my query to tell it to pad each field with spaces if the
value is not the size of the field?

Why?

If you're using the Query datasheet for printing or data display, just Don't
Do That. It's not what queries are designed for! Use a Report instead; you can
display the data in a textbox, left justified or right justified as you
prefer.

If you're exporting the data to a text file, same thing - specify the size of
the field in the export specification.
 
N

Natalie

I don't need a report for this I am trying to export the data the query pulls
to a flat file. The feilds need to be padded with spaces...I thought someone
might know a funciton I could use to do this.
Karl's suggestion works for text field, but not numeric feilds (Many Thanks).
 
J

John W. Vinson

I don't need a report for this I am trying to export the data the query pulls
to a flat file. The feilds need to be padded with spaces...I thought someone
might know a funciton I could use to do this.
Karl's suggestion works for text field, but not numeric feilds (Many Thanks).

You could use Right(Space(14) & Format([fieldname],#), 14)
 
K

KARL DEWEY

This worked on my Access 2003, SP2.
SELECT Right(" " & [NumberField],14) AS Expr2,
Format([DateField]," mm/dd/yyyy") AS Expr1
FROM [Change Requests];
 
N

Natalie

Awsome...that worked out great. Thanks much for all your help.


KARL DEWEY said:
This worked on my Access 2003, SP2.
SELECT Right(" " & [NumberField],14) AS Expr2,
Format([DateField]," mm/dd/yyyy") AS Expr1
FROM [Change Requests];

--
KARL DEWEY
Build a little - Test a little


Natalie said:
I don't need a report for this I am trying to export the data the query pulls
to a flat file. The feilds need to be padded with spaces...I thought someone
might know a funciton I could use to do this.
Karl's suggestion works for text field, but not numeric feilds (Many Thanks).
 

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