Applies To ActiveX control, Bound Object Frame control, Chart control, Check Box control, Combo Box control, List Box control, Option Button control, Option Group control, Text Box control, Toggle Button control.
Description
You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. For a report group level, the ControlSource property determines the field or expression to group on.
Note The ControlSource property doesn't apply to check box, option button, or toggle button controls in an option group. It applies only to the option group itself. For reports, the ControlSource property applies only to report group levels.Setting
The ControlSource property uses the following settings.
Setting | Description |
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address. |
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database. |
Sample Setting | Description |
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name. |
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control. |
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date. |
See Also Load, Unload events, RecordSource property, RowSourceType, RowSource properties.
Example The following example sets the ControlSource property for a text box named AddressPart to a field named City:Forms!Customers!AddressPart.ControlSource = "City"
The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7.
Me!Expected.ControlSource = "=Date() + 7"