ControlType Property

Applies To

Bound Object Frame Control, Chart Control, Check Box Control, Color Builder, Combo Box Control, Command Button Control, Image Control, Label Control, List Box Control, Option Button Control, Page Break Control, Subform/Subreport Control, Text Box Control, Toggle Button Control, Unbound Object Frame Control.

Description

You can use the ControlType property in Visual Basic to determine the type of a control on a form.

Note The ControlType property applies only to controls on a form.

Setting

The ControlType property setting is a constant corresponding to an Integer value that specifies the control type.

Constant Value Control
acLabel 100 Label
acRectangle 101 Rectangle
acLine 102 Line
acImage 103 Image
acCommandButton 104 Command button
acOptionButton 105 Option button
acCheckBox 106 Check box
acOptionGroup 107 Option group
acBoundObjectFrame 108 Bound object frame
acTextBox 109 Text box
acListBox 110 List box
acComboBox 111 Combo box
acSubform 112 Subform
acObjectFrame 114 Unbound object frame
acPageBreak 118 Page break
acCustomControl 119 Custom control
acToggleButton 122 Toggle button


The ControlType property can only be set using Visual Basic in form Design view but can be read in all views.

Remarks

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don’t want certain users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form’s AllowEdits property to No. The SpecialEffect property does not affect whether data can be edited; it is used here to provide a visual clue that the control behavior has changed.

The ControlType property is also used to specify the type of control to create using the CreateControl function.

See Also

CreateControl, CreateReportControl Functions.

Example

See the AllowAdditions property example.