Link to home
Start Free TrialLog in
Avatar of bemara57
bemara57

asked on

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

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?
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

You can use the Space() function instead of Pad

mx
SELECT Right("          " & nbr, 10) AS PaddedNbr
FROM SomeTable
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of puppydogbuddy
puppydogbuddy

SELECT Format([YourNumber],"0000000000") AS NewNbr FROM [YourTable];