【发布时间】:2017-04-04 21:19:51
【问题描述】:
我很长时间不使用 VBA....我在 Access 2016 中有这个表格
当我尝试通过 Me.Controls 集合访问各种 TextBox 并将其转换为 TextBox 对象时,我得到一个 Null 引用 但它的某些属性是有效的(例如 tb.Name)
Private Sub Form_Load()
Dim ctrl As Control
Dim tb As TextBox
Dim evTb As clsEventTextBox
Set m_TbColl = New Collection
For Each ctrl In Me.Controls
If Left$(ctrl.Name, 4) = "Txt_" Then
Set tb = ctrl
'Create the TextBox wrapper
Set evTb = New clsEventTextBox
Set evTb.EventsHandler = Me
Set evTb.InnerTextBox = tb <----- HERE tb Is NULL
m_TbColl.Add evTb, ctrl.Name
End If
Next
End Sub
我错过了什么?
另外,有没有办法获取控件的类型而不是使用
Left$(ctrl.Name, 4) = "Txt_"
【问题讨论】:
标签: ms-access vba ms-access-2016