我知道设置列宽最适合具有“标题”名称的字段,以下代码有效:
Private Sub Form_Load()
Forms![Contacts]![Title].ColumnWidth = -2
End sub
数据表视图中的所有列的解决方案是一行还是两行VBA代码?
非常感谢...
答案 0 :(得分:0)
Dim f As Object
Set f = Forms![Contacts]
' Or Set f = Me.Form
Dim c As Control
For Each c In f.Controls
With c
' If textbox
If .ControlType = acTextBox Then
' Adjust to best fit width
.ColumnWidth = -2
End If
End With
Next c
Set c = Nothing
Set f = Nothing