I have a loop that I use in my standard module that clears a forms text boxes. It works fine in other programs I have deployed. But at the company I work with now I am getting error 458 Automation not supported in VB.
Is there a way to late bind the controls to do what I want it to do?
Public Sub ClearText(frm As Form)
'Used to clear all text and pertinent labels by passing in the form
'name and tagging labels that are to be cleared
Dim ctl As Control
For Each ctl In frm.Controls
If ctl.Tag = False Then
GoTo Skip
ElseIf TypeOf ctl Is TextBox Then
ctl.Text = ""
If ctl.Tag = "tcl" Then
ctl.Visible = False
End If
End If
If TypeOf ctl Is Label And ctl.Tag = "clf" Then
ctl.Caption = ""
End If
If TypeOf ctl Is CheckBox And ctl.Tag = "ccb" Then
ctl.Value = vbUnchecked
ctl.Visible = False
ElseIf TypeOf ctl Is CheckBox And ctl.Tag = "cckb" Then
blnClearForm = True
blnNoEvent = True
ctl.Value = vbUnchecked
blnClearForm = False
End If
Skip:
Next ctl
End Sub
Any help would be greatly appreciated.
Joanne
Is there a way to late bind the controls to do what I want it to do?
Public Sub ClearText(frm As Form)
'Used to clear all text and pertinent labels by passing in the form
'name and tagging labels that are to be cleared
Dim ctl As Control
For Each ctl In frm.Controls
If ctl.Tag = False Then
GoTo Skip
ElseIf TypeOf ctl Is TextBox Then
ctl.Text = ""
If ctl.Tag = "tcl" Then
ctl.Visible = False
End If
End If
If TypeOf ctl Is Label And ctl.Tag = "clf" Then
ctl.Caption = ""
End If
If TypeOf ctl Is CheckBox And ctl.Tag = "ccb" Then
ctl.Value = vbUnchecked
ctl.Visible = False
ElseIf TypeOf ctl Is CheckBox And ctl.Tag = "cckb" Then
blnClearForm = True
blnNoEvent = True
ctl.Value = vbUnchecked
blnClearForm = False
End If
Skip:
Next ctl
End Sub
Any help would be greatly appreciated.
Joanne