Changing a Control Type

You can change the type of a control on a form, providing that the change does not break any rules regarding the control that can be the parent and the type of child control types that are permitted.

The control name, event method code, and so on, are retained, so that you do not have to first delete the existing control, add the replacement control of the required type, and then create the appropriate event methods.

To change the existing type of a control selected on a form

  1. Select the Change Type command from the Controls menu.

    If the selected control has existing method references, a message box then displays the name of the control and the number of methods that reference it, advising you that the methods will be marked for recompile. Click the Yes button to confirm that you want to change the control type now. When you save the form (by selecting the Save Form command from the File menu), all method references to the control are then automatically recompiled during the save operation. (Alternatively, click the No button if you want to abandon the changing of the control type.)

    The Change Control Type dialog is then displayed. The name property and the existing type of the selected control are displayed in the Control and Current Type text boxes, respectively. As these are read-only for information purposes, you cannot change these values.

  2. In the New Type list box, select the new type that you require for the control. The control type that you select must conform to the rules about the permitted parent control and child control types. For example, you can change a GroupBox control that contains child controls to a Frame but you cannot change it to a Folder (as a Folder control can have only Sheet controls as children).

    Although you cannot change a GroupBox control that has children to a Button control (as Button controls cannot have children), you can change a GroupBox control that does not have children to a Button control. If the selected control type is invalid, a message box is then displayed. Click the OK button to return to the Change Control Type dialog and select a valid control type.

  3. When you have selected a valid control type, click the OK button in the Change Control Type dialog. Alternatively, click the Cancel button to abandon your selection.