RowSourceType, RowSource Properties

RowSourceType, RowSource Properties

See Also         Example         Applies To

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.

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.

The RowSource property setting depends on the RowSourceType property 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.

Note   If the RowSourceType property is set to a user-defined function, the RowSource property can be left blank.

You can set the RowSourceType and RowSource properties by using the control's property sheet, a macro, or Visual Basic.

For table fields, you can set these properties on the Lookup tab in the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

Note   Microsoft Access sets these properties automatically when you select Lookup Wizard as the data type for a field in table Design view.

In Visual Basic, set the RowSourceType property by using a string expression with one of these values: "Table/Query", "Value List", or "Field List". You also use a string expression to set the value of the RowSource property. To set the RowSourceType property to a user-defined function, enter the name of the function.

Remarks

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.