Forum Discussion
Joaquin256
Aug 31, 2022Copper Contributor
Columns Size in List for VBA Access
Hi, II am working on a query form in access, where I have a textbox in which I type the value to search for, which will then load them in the listed object (as if it were a datagrid or a list). ...
- Sep 02, 2022
see this demo using Stephen Lebans code (class).
arnel_gp
Sep 01, 2022Iron Contributor
if it is a Datasheet you are talking, you can Resize the Column by setting the ColumnWidth = -2 (best fit).
you can add code to the "subform" Load event:
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Detail.Controls
If ctl.ControlType = 109 Then
ctl.ColumnWidth = -2
End If
Next ctl
End Sub
Public Sub ResizeColumns()
Call Form_Load
End Sub
you also need code to the AfterUpdate event of your textbox:
Private Sub TextSearch_AfterUpdate()
Me.theSubformName.Requery
Me.theSubformname.Form.ResizeColumns
End Sub
Joaquin256
Sep 01, 2022Copper Contributor
Can that routine be applied to a list box?
- arnel_gpSep 02, 2022Iron Contributor
see this demo using Stephen Lebans code (class).