?
Solved

How do I pad spaces to a SELECT field in MS Access?

Posted on 2007-07-28
4
Medium Priority
?
4,268 Views
Last Modified: 2012-05-05
How do I pad left to a field I select so it is always 10 characters long (padded with spaces. So this:

2834
02149803
203985
234

Would become this in my SELECT statment:
      2834 (padded 6 spaces to the left of the number)
  02149803 (padded 2 spaces to the left of the number)
    203985 (padded 4 spaces to the left of the number)
       234 (padded 7 spaces to the left of the number)

I'm looking for something in MS Access where I can do something like SELECT PAD(nbr," ") FROM table. Anything like this exist?
0
Comment
Question by:bemara57
  • 2
4 Comments
 
LVL 75
ID: 19585673
You can use the Space() function instead of Pad

mx
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 19585675
SELECT Right("          " & nbr, 10) AS PaddedNbr
FROM SomeTable
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 19585694
Space(10-Len("2834")) & "2834"

returns six spaces in front of 2834

mx
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 19585762
SELECT Format([YourNumber],"0000000000") AS NewNbr FROM [YourTable];
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question