Applies To Chart control, Combo Box control, List Box control, Table field, Unbound Object Frame control.
Description
You can use the RowSourceType and RowSource properties together to tell Microsoft Access how to provide data to a list box, a combo box, or an unbound OLE object such as a chart. For example, to display rows of data in a list box from a query named CustomerList, set the list box's RowSourceType property to Table/Query and its RowSource property to the query named CustomerList.
Setting
The RowSourceType property uses the following settings.
Setting | Description |
Table/Query | (Default) The data is from a table, query, or SQL statement specified by the RowSource setting. |
Value List | The data is a list of items specified by the RowSource setting. |
Field List | The data is a list of field names from a table, query, or SQL statement specified by the RowSource setting. |
For this RowSourceType Setting | Enter this RowSource Setting |
Table/Query | A table name, query name, or SQL statement. |
Value List | A list of items with semicolons (;) as separators. |
Field List | A table name, query name, or SQL statement. |
See Also BoundColumn property, ColumnWidths property, ControlSource property, RecordSource property, RowSourceType property (user-defined function) — code argument values.
Example The following examples show sample RowSource property settings for each RowSourceType property setting. When the RowSourceType Property Is Set to Value List If the RowSourceType property is set to Value List, the following table shows valid settings for the RowSource and ColumnCount properties and an illustration of the resulting list.RowSource Setting | List |
Mon;Tue;Wed (ColumnCount = 1) | One-column list with three rows |
1;Monday;2;Tuesday;3;Wednesday;4;Thursday (ColumnCount = 2) | Two-column list with four rows |
Country;Capital;China;Beijing;Brazil;Brasilia (ColumnCount = 2, ColumnHeads = Yes) | Two-column list with one row of column heads and two rows of data |
SELECT CategoryID, CategoryName FROM Categories ORDER BY CategoryName;
If the CategoryList query and the SQL statement define the same set of records, the list for either property setting looks like the following illustration.
When the RowSourceType Property Is Set to Field List
If the RowSourceType property is set to Field List and the RowSource property to CategoryList (the query described in the previous example), the resulting list looks like the following illustration.
When the RowSourceType Property Is Set to a User-Defined Function
If the RowSourceType property is set to the name of a user-defined function, then the RowSource property setting can be left blank. For example, a user-defined function named ListMDBs that fills a combo box with the names of all the databases in the current directory is entered in the property sheet as in the following illustration.
Example
The following example sets the RowSourceType property for a combo box to Table/Query, and it sets the RowSource property to a query named EmployeeList.
Forms!Employees!cmboNames.RowSourceType = "Table/Query"
Forms!Employees!cmboNames.RowSource = "EmployeeList"