Right justify a list box column

M

M Skabialka

I have one column in a list box that is numbers from 1 to 100,000,000, which
would look better if right justified. I downloaded a Stephan Lebans sample
database written in 1999 but couldn't get it to work - the column appeared
blank. I also tried to prefill the front of the number with spaces
depending on its size using a long SWITCH statement, but am wondering if
there isn't a better way.
I am using Access 2003 on Windows XP.
Has anyone come up with a more elegant solution?
Mich
 
J

John Spencer

This will give you a result that is always 10 characters long and be right
justified. It isn't the most elegant thing, but it would be a lot better than
a complex switch statement. Just change the two "12"s to whatever number of
characters you want to display.

Right(Space(12) & YourField,12)

If you need formatting to include the commas then you will need to use the
format function around YourField.

Right(Space(12) & Format(YourField,"#,###"),12)

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
M

M Skabialka

I had to use double the number of spaces using the Tahoma font, but this
worked great.
Space(16-Len([MyNumber])*2) & Format([MyNumber, "#,###)
Thanks - didn't know about the Space command!
Mich
 

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