VBA & Macro Problems

Change Access List Box Column Widths with VBA

Kushani NimanthikaKushani Nimanthika Nov 22, 2026 868 views

Question details

Change a Microsoft Access list box's column count and widths when an option group selects a different row source.

Change Access List Box Column Widths with VBA
Product
Microsoft Access
Device & OS
not provided
Scenario
A form uses an option group to switch the list box between row sources with different columns.
Observed behavior
The list box does not consistently display the expected columns and widths after the row source changes.
Before you start

Open the form in Design View and check the names of the option group and list box in their property sheets. Identify the option values and the fields returned by each row source.

Solution 1Recommended

Update the list box in the option group's After Update event

Use this approach to apply the correct row source, column count, and widths whenever the selection changes.

Set ColumnCount to the number of fields returned by the selected row source. Provide a semicolon-separated width for each column; a width of 0 hides that column.

The following example assumes an option group named grpView, a list box named lstResults, and option values of 1 and 2. Replace the control names, table names, fields, and widths with those used in your form.

1
Open the event procedure

In Form Design View, select the option group, open its Property Sheet, and choose Event > After Update > [Event Procedure]. Click the ellipsis button to open the VBA editor.

2
Add the selection logic

Add this code inside the event procedure, using your own field and table names: Select Case Me!grpView.Value Case 1 Me!lstResults.ColumnCount = 3 Me!lstResults.ColumnWidths = "0 in;1.5 in;2 in" Me!lstResults.RowSource = "SELECT ClientID, ClientName, Email FROM Clients" Case 2 Me!lstResults.ColumnCount = 2 Me!lstResults.ColumnWidths = "0 in;2 in" Me!lstResults.RowSource = "SELECT ProductID, ProductName FROM Products" End Select Me!lstResults.Requery

3
Test each option

Return to Form View and select each option in grpView. Check that the visible columns and their widths match the fields returned by each row source.

Update the list box in the option group's After Update event
Check the width values: Incorrect widths caused the original issue. If a column is missing, check whether its width is 0 and whether the width values are in the same order as the row source fields.
Free Microsoft Office alternative

Work with exported Access data in WPS Spreadsheets

WPS Office is a free, lightweight alternative with a familiar interface for viewing and editing spreadsheet data. Export Access data to Excel to move it into WPS Spreadsheets; WPS does not run Access forms or fix their VBA.

Review and adjust column widths in spreadsheet data exported from AccessOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface for an easier transitionWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Where should I put the list box update code?

Place it in the option group's After Update event. In Form Design View, select the option group and open Property Sheet > Event > After Update.

Why is a list box column not visible?

Check the list box's Column Widths property or the ColumnWidths value in VBA. A width of 0 hides a column, and the widths must follow the order of the fields in the row source.

How many widths should I specify?

Specify one semicolon-separated width for each column returned by the row source, and set ColumnCount to that number. For example, three columns could use "0 in;1.5 in;2 in".

Will the After Update event set the list box when the form first opens?

Not by itself. After Update runs when the option group's value changes. If the list box also needs initial settings, call shared update code from the form's Load event.