The form's Controls
collection only contains the top-level controls that are placed directly on the form. If you load a control into a container control, such as a GroupBox
, you must find it in that container control's Controls
collection.
So, instead of doing this:
Me.Controls(strCheckBoxOldName).Name = strCheckBoxNewName
You should be doing something like this:
Me.Controls(strControlName).Controls(strCheckBoxOldName).Name = strCheckBoxNewName