C
chammock
I am using VBA to create about 150 command buttons on a page with click
events. Each buttton is named cmd*, where * is a row and column number,
like cmdA1. I wanted a quick way to delete the buttons from the Detail
Section during testing. I am using the following code. I have stepped
through the process, which works, but it only deletes every other
control on the page. If I run it again it deletes 1/2 again. Why would
it only be getting 1/2 of the controls on each iteration? Also, can I
just select ALL controls in the Detail Section at once to delete? There
is other info in the header/footer that I don't want to delete.
DoCmd.OpenForm "frmPanelRightTemplate", acDesign, , , , acWindowNormal
Dim varControl As Variant
For Each varControl In Forms![frmPanelRightTemplate].Controls
MsgBox (varControl.Name) ' used for testing only
If Mid(varControl.Name, 1, 3) = "cmd" Then 'In design view set the tag
property of the control to "Visible
DeleteControl "frmPanelRightTemplate", varControl.Name
End If
Next
DoCmd.Save
DoCmd.OpenForm "frmPanelRightTemplate"
events. Each buttton is named cmd*, where * is a row and column number,
like cmdA1. I wanted a quick way to delete the buttons from the Detail
Section during testing. I am using the following code. I have stepped
through the process, which works, but it only deletes every other
control on the page. If I run it again it deletes 1/2 again. Why would
it only be getting 1/2 of the controls on each iteration? Also, can I
just select ALL controls in the Detail Section at once to delete? There
is other info in the header/footer that I don't want to delete.
DoCmd.OpenForm "frmPanelRightTemplate", acDesign, , , , acWindowNormal
Dim varControl As Variant
For Each varControl In Forms![frmPanelRightTemplate].Controls
MsgBox (varControl.Name) ' used for testing only
If Mid(varControl.Name, 1, 3) = "cmd" Then 'In design view set the tag
property of the control to "Visible
DeleteControl "frmPanelRightTemplate", varControl.Name
End If
Next
DoCmd.Save
DoCmd.OpenForm "frmPanelRightTemplate"