-
I am trying to remove dynamically created textboxes and labels that I created on a form. The event that I want to remove them with is the click on a combo box. Microsoft help tells me I cannot do an unload of these controls with the combo event.
The txt and lbl are created dynamically based on a recordset retrieved from the new combo value. I have it working from a clear form button, but this is junky looking. It should clear on the new selection in the combo.
Any ideas of how to get around this?
Thanks in advance!!!!!
-
try adding a timer to your form and setting it's interval to 1 and disable it at start.
add something like this to your form
Code:
Dim objRemove As Object
Private Sub Timer1_Timer()
Unload objRemove
Set ObjRemove = Nothing
Timer1.Enabled = False
End Sub
Private Sub RemoveObject (Obj as Object)
Set objRemove = Obj
Timer1.Enabled = True
End Sub
Then use the remove object sub to remove your control
Hope this helps.
-
or you can use load
Have a text array,
for example.
txtBoxes(0)
to create a new "txtBoxes(0)"
Code:
Dim MaxID As Integer
MaxID = txtBoxes.Count
Load txtBoxes(MaxID)
to delete:
Code:
Dim MaxID As Integer
MaxID = txtBoxes.Count
UnLoad txtBoxes(MaxID)