Murray Brown
asked on
Access VBA widen ListBox columns to fit data
Hi
I am using the following code to fill a listbox in Access but the columns are not wide enough. How do I widen the columns to automatically fit the data
I am using the following code to fill a listbox in Access but the columns are not wide enough. How do I widen the columns to automatically fit the data
Private Sub Report_Open()
Dim Query As DAO.QueryDef
Debug.Print oReportSQL
If oReportSQL <> "" Then
Set Query = CurrentDb.CreateQueryDef("", oReportSQL)
Me!ListSql.ColumnCount = Query.Fields.Count
Me!ListSql.RowSource = oReportSQL
Query.Close
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or you could use a datasheet subform instead of the listbox. Added advantages of:
1. justification within a column
2. Sorting and filtering in the datasheet
3. Setting column widths on the fly
4. Hiding columns the user doesn't need
5. Moving columns to a user specified sequence.
You can even allow users to save their preferences when you do it this way. Check out my article on Customizing Datasheets to Users needs
1. justification within a column
2. Sorting and filtering in the datasheet
3. Setting column widths on the fly
4. Hiding columns the user doesn't need
5. Moving columns to a user specified sequence.
You can even allow users to save their preferences when you do it this way. Check out my article on Customizing Datasheets to Users needs
ASKER
Thanks very much
to adjust the columns nicely