Formatting columns in as List Box

RaptorRaptur

Member
Local time
Today, 17:43
Joined
May 15, 2021
Messages
74
Is there a way to format columns in a list box containing different forms of data. So a list box contains a few columns with text - align left. But then a column with amounts in it which I would like to right align and present in the format 99,999,999.99

Not that I need it now, but a date field as dd/mm/yyyy as well.

Regards,

Alan
 
A fixed space font with spaces as padding could work and might be the easiest.
 
Maybe another option is to use a subform as a listbox?
 
Padding with format and spacing with a fixed width font.

Example query
Code:
SELECT
    tblGLPost.Account,
    Right(space(15) & tblGLPost.Debit, 15) As RightJust,
    Format([tblGLPost].[PostDate], "dd/mm/yyyy") AS TheDate
    FROM tblGLPost
    WHERE Format([tblGLPost].[PostDate], "dd/mm/yyyy) < #4 / 9 / 2026#
    AND tblGLPost.Debit > 0;

Combo without fixed width font
1775845907551.png
 
Thanks guys,
I appreciate all the comments and advice. However, I think I will swap over from a list box to a sub form as the dbGuy suggested. Ron's suggestion about using a query as he posted is certainly an option to consider.
thank you,

Alan
 
I appreciate all the comments and advice. However, I think I will swap over from a list box to a sub form

The attached little demo file illustrates how to simulate a list box by means of a subform. In the demo there is just one visible control (txtParish) in the subform's detail section, but it would be a simple matter to have two, side by side. In the demo a second control bound to the District column could be added for instance. Each control can then be formatted differently.

In addition to the visible control in the detail section, this is underlain by a hidden unbound text box control. Code in the subform's Current event procedure assigns the value of the currently selected row's primary key to this control. This facilitates conditional formatting of controls in the detail section. The two text box controls are overlain by a transparent command button, whose Click event procedure determines what action is to be undertaken when a row is selected.

Apologies for the lurid colour scheme in the demo. This was done deliberately to emphasise the formatting possibilities. An operational database would be more tasteful!
 

Attachments

Users who are viewing this thread

Back
Top Bottom