Padding spaces to string

J

John

Hi

How can I pad spaces to the right of a string so the total length is say 50?

Thanks

Regards
 
F

fredg

Hi

How can I pad spaces to the right of a string so the total length is say 50?

Thanks

Regards

=MyString & Space(50-Len(MyString))

Where you place the above expression depends upon where you are doing
this.
 
J

Jeff Boyce

John

Where?

Why?

You've provided a solution ("pad to 50").

If we knew more about what you want to do with the string that you believe
needs padding to 50 characters, we might be able to offer alternate ideas.

Take a look at using a query to concatenate [YourString] and Spaces(50),
then take the leftmost 50 characters (Left(...),50).

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
L

Larry Linson

If I recall correctly, Access truncates trailing spaces when it writes to
disk, so you can't count on them being there when you next read the record.
I'd think it "unusual" if any application logic ware dependent on trailing
spaces.

Larry Linson
Microsoft Office Access MVP
 
J

John Spencer (MVP)

Trailing spaces are truncated when entered via the keyboard (or through a
form). On the other hand if you use a query to put them in they will remain
until the field is edited.

If this is for export purposes, then I would use a query and a calculated field.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

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