RowSourceType Property

Microsoft Access Visual Basic

RowSourceType Property

       

You can use the RowSourceType property (along with the RowSource property) 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. Read/write String.

expression.RowSourceType

expression   Required. An expression that returns one of the objects in the Applies To list.

Remarks

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.
Note   You can also set the RowSourceType property with a user-defined function. The function name is entered without a preceding equal sign (=) and without the trailing pair of parentheses. You must provide specific function code arguments to tell Microsoft Access how to fill the control.

You can set the RowSourceType property by using the control's property sheet, a macro, or Visual Basic. In Visual Basic, set the RowSourceType property by using a string expression with one of these values: "Table/Query", "Value List", or "Field List". To set the RowSourceType property to a user-defined function, enter the name of the function.

When you have a limited number of values that don't change, you can set the RowSourceType property to Value List and then enter the values that make up the list in the RowSource property.

When you create a user-defined function to insert items into a list box or combo box, Microsoft Access calls the function repeatedly to get the information it needs. User-defined RowSourceType functions must be written in a very specific function format.

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"