Right Align listbox columns Access 2010 (1 Viewer)

kirkm

Registered User.
Local time
Tomorrow, 08:25
Joined
Oct 30, 2008
Messages
1,257
I don't think it's possible ? Source is a value list. I tried adding spaces but they're ignored. Then found
  1. Convert the listbox to combobox
  2. Make the combobox that you converted right alignment
  3. Convert it again to listbox
But that didn't work either.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:25
Joined
Oct 29, 2018
Messages
21,469
Hi. If it's not possible, then maybe the next best thing is to use a subform that looks like a listbox.
 

Micron

AWF VIP
Local time
Today, 16:25
Joined
Oct 20, 2018
Messages
3,478
From what I've read, solutions may be version dependent because aligning the table is supposed to work in 2007 so who knows about that one. Lebans apparently has some API code to do this but I've never looked at it.
 

kirkm

Registered User.
Local time
Tomorrow, 08:25
Joined
Oct 30, 2008
Messages
1,257
I did look at Lebans but it was too complex to figure out what bits I'd need. The I read about using a table (inheriting justification) but I can't find any justification options in table design ! The subForm idea is worth trying so will have a shot at that.
Thanks.
 

Micron

AWF VIP
Local time
Today, 16:25
Joined
Oct 20, 2018
Messages
3,478
I would think they simply meant justifying text alignment by using the ribbon. I tried that but it made no difference to a listbox. Mind you, the listbox was based on a query of that table and not the table itself.
 

mamradzelvy

Member
Local time
Today, 22:25
Joined
Apr 14, 2020
Messages
145
I don't think it's possible ? Source is a value list. I tried adding spaces but they're ignored. Then found
  1. Convert the listbox to combobox
  2. Make the combobox that you converted right alignment
  3. Convert it again to listbox
But that didn't work either.
Hi mate, it's a bit obnoxious, but here's the only solution i managed to get working.
So uh, don't have it as a value list, make a table instead where you will have your values, then open the design view of the table, select the column and in the properties menu on the bottom switch text alignment from "general" to "right" and then on your list box switch from "value list" to "query/table" and set the rowsource to for instance "SELECT col1 FROM tblList;"

lstbx.PNG


PS: uh oh, didn't notice you were using 2010, i have not tested that in any older access, sorry!!
 

Micron

AWF VIP
Local time
Today, 16:25
Joined
Oct 20, 2018
Messages
3,478
Interesting. Went back to the same form, used the Text Align property in table design and my listbox columns became right justified. I guess just using the ribbon to align table fields is only a kind of formatting and doesn't alter the actual layout of the underlying data.
 

kirkm

Registered User.
Local time
Tomorrow, 08:25
Joined
Oct 30, 2008
Messages
1,257
Thanks for that mamradzelvy, I'll try it tomorrow, really late here now. I never noticed the scroll bar and Text align option. Duh! That might allow both L aligned and R aligned which is actually what's wanted. I am using Access 2010 as still mainly prefer XP (LOL), but have Office 2019 on Win10 machine. This database is for someone with Access 2007 though. Could be interesting. I'll let you know.
 

kirkm

Registered User.
Local time
Tomorrow, 08:25
Joined
Oct 30, 2008
Messages
1,257
mamradzelvy suggestion works in Access 2010. In fact it's really good but gee have I struck a real brick wall trying to figure out what Access is doing.
Is the number of columns in a list box limited to 9 ?
Because the attached only shows 9 columns- ignoring a tenth field in the table called 'Direction'

Wondering if the listbox width may be the problem, I then found the its width would not change
Form width is set in Load event with MoveSize to 25000, but printing this in the debug.window says its 16610

The command Listbox1.Width= Me.Width in Form Load is ignored and list width debug.prints as 15647. In list properties this is shown as 25.317cm. I don't know how to correlate the two. By the way, which take precedence, properties or code in Form Load ?

So I've been a few hours unsuccessfully trying to figure out
1) Why Form width isn't 25000
2) Why list width isn't changing to Form width as instructed (or any other width in Form Load)
3) Why not all the list columns are showing.

Thanks for any answers.
 

Attachments

  • DatabaseListProblem.accdb
    424 KB · Views: 137

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 06:25
Joined
Jan 20, 2009
Messages
12,852
The command Listbox1.Width= Me.Width in Form Load is ignored and list width debug.prints as 15647. In list properties this is shown as 25.317cm. I don't know how to correlate the two. By the way, which take precedence, properties or code in Form Load ?

These measurements are Twips. A Twip is a TWentieth of an Imperial Point.
There are about 567 twips to a cm.
 

kirkm

Registered User.
Local time
Tomorrow, 08:25
Joined
Oct 30, 2008
Messages
1,257
Thanks, good to know. So which one (control properties) or Form Load event is used ?
 

kirkm

Registered User.
Local time
Tomorrow, 08:25
Joined
Oct 30, 2008
Messages
1,257
After much playing around I think the db I uploaded must have a bug. I determined a Listbox has 10 Cols max and had no Record Source to bind it to a table. But you can set its Row Source to a table.
Making a new Form and listbox things are starting to make sense.
 

kirkm

Registered User.
Local time
Tomorrow, 08:25
Joined
Oct 30, 2008
Messages
1,257
Just as an afterthougt, if anyone looks at the attachemnt in msg 9 and can see why having 10 clumns doesn't work, please let me know. I suspect it's Access being weird. A duplicate remade exactly the same is fine.
 

Users who are viewing this thread

Top Bottom