Pad a column alias' with a leading space.

builttorock

New member
Local time
Today, 06:05
Joined
Jan 20, 2025
Messages
4
Help please!
I have a list box that is populated by a SQL query in VBA. I want to pad the column/field name with 2 leading spaces.

Right now I am using this in my SQL statement:

T_Invoice.Ship_Date AS [SHIP DATE]

to display SHIP DATE as the column heading in the list box which works fine. However, I want two leading spaces before the word SHIP.

I tried using T_Invoice.Ship_Date AS [ SHIP DATE] with a leading space before the word SHIP but it does not work.

Seems MS Access SQL does not like the leading space. Any idea how to make this work?
Thanks,
 
Formatting. Trying to center the column name in the list box.
 
Huh? The column name doesn't display.

The label of the list box does display-- center that (or add leading spaces to it) instead of trying to fix a formatting issue in SQL.
 
I would not use the column heads if you want that format. Instead I would go with a label over the listbox.
f.PNG

Just look at your column widths. Create the labels and set them to the matching width. Then then would be the correct size. You cannot drag them because the columns do not show in design view.

This looks way nicer in my opinion because you can bold or format the label and make it stand out.
f2.PNG
 
Hi. Welcome to AWF!

I agree with the previous suggestion. But if spaces don't work in SQL, maybe you could try using a hard space.
 
Did you use Space(2) & SomeName? Always post your code or query when it doesn't work. We can't guess what you did wrong.
 
thanks Pat for the reply and I did try and use your suggestion of Space(2) & Field_Name but it doesn't work inside a VBA module that has a SQL statement.
I ended up using MajP's suggestion above of using labels and turning off column headers. Labels allows for more formatting flexibility.

 

Users who are viewing this thread

Back
Top Bottom