looping through a Form and deleting all controls!
Hi People,
I have a manu form which has a command button. When the button is press it should open a form called FrmBank2 and delete all controls on the form by looping through them. The problem is only 6 controls (textboxes) get deleted and the rest of the controls (Textboxes) remain on the form. I need to delet all the textboxes on the form?. I am using the following code -
Dim ctrlCntrl As Control
Dim frmParent1 As Form
DoCmd.OpenForm "FrmBank2", acDesign, , , , acHidden
Set frmParent1 = Forms!FrmBank2
For Each ctrlCntrl In frmParent1.Controls
DeleteControl frmParent1.Name, ctrlCntrl.Name
Next ctrlCntrl
End Sub
Any ideas as to what might be the problem.
Thanks!!!
Hi People,
I have a manu form which has a command button. When the button is press it should open a form called FrmBank2 and delete all controls on the form by looping through them. The problem is only 6 controls (textboxes) get deleted and the rest of the controls (Textboxes) remain on the form. I need to delet all the textboxes on the form?. I am using the following code -
Dim ctrlCntrl As Control
Dim frmParent1 As Form
DoCmd.OpenForm "FrmBank2", acDesign, , , , acHidden
Set frmParent1 = Forms!FrmBank2
For Each ctrlCntrl In frmParent1.Controls
DeleteControl frmParent1.Name, ctrlCntrl.Name
Next ctrlCntrl
End Sub
Any ideas as to what might be the problem.
Thanks!!!