Hello all,
I am using the following code to clear all of the textboxes and comboboxes on a form.
Code:
Private Sub Form_Load()
Dim oneControl As Object
intStartNo = 1
For Each oneControl In Me.Controls
Select Case oneControl.ControlType
Case acTextBox
oneControl.Value = ""
Debug.Print oneControl.Name
Case acComboBox
oneControl.Value = ""
Debug.Print oneControl.Name
End Select
Next oneControl
Me.tbxMatSetID = intStartNo
Me.tabSpotData.Visible = False
Me.tabStudData.Visible = False
Me.tabGTAWData.Visible = False
Me.tbxMatSetID = intStartNo
Me.tbxTackSetID = intStartNo
Me.tbxTechSetID = intStartNo
End Sub
I initally got a "Run Time Error 2448 - You cannot assign a value to this object" on one of the textboxes. It happened about 3/4 of the way through all of the controls. After searching all of the properties for what might be causing this, I deleted the textbox and recreated it. When I ran it again, I got the same error, but this time on the control before the replaced one. (I have a breakpoint at the beginning of the Select Case and am stepping through while watching the list appear in the Immediate Window.) I replaced that one, and the problem moved up to the one before it. I have done this for all 7 controls on the tab. Now, It has jumped back to the last control on the previous tab.
This seems very peculiar, and other than working backwards through the controls, has no obvious cause. Does anyone have any suggestions?