ComboBox.RowSourceType 屬性 (Access)ComboBox.RowSourceType property (Access)

您可以使用 (搭配RowSource屬性) 的RowSourceType屬性來告知 Microsoft Access 如何提供資料給指定的物件。You can use the RowSourceType property (along with the RowSource property) to tell Microsoft Access how to provide data to the specified object. 可讀寫的 StringRead/write String.

語法Syntax

運算式資料來源類型expression.RowSourceType

_運算式_代表**ComboBox** 物件的變數。expression A variable that represents a ComboBox object.

註解Remarks

RowSourceType 屬性使用下列設定值。The RowSourceType property uses the following settings.

設定Setting 描述Description
資料表/查詢Table/Query (預設值) 此資料取自 RowSource 設定值所指定的資料表、查詢或 SQL 字串/陳述式。(Default) The data is from a table, query, or SQL statement specified by the RowSource setting.
值清單Value List 此資料是 RowSource 設定值所指定的項目清單。The data is a list of items specified by the RowSource setting.
欄位清單Field List 此資料是取自 RowSource 設定值所指定資料表、查詢或 SQL 陳述式之欄位名稱的清單。The data is a list of field names from a table, query, or SQL statement specified by the RowSource setting.

注意

[!注意事項] 您也可以設定 RowSourceType 屬性使用者定義的函數。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 Access how to fill the control.

在 Visual Basic 中設定的RowSourceType屬性使用下列其中一個這些值的字串運算式: 「 資料表/查詢 」、 「 [值] 清單 」 或 [欄位清單]。In Visual Basic, set the RowSourceType property by using a string expression with one of these values: "Table/Query", "Value List", or "Field List". 您也可以使用字串運算式來設定 RowSource 屬性的值。You also use a string expression to set the value of the RowSource property. 若要將 RowSourceType 屬性設為使用者定義的函數,輸入函數的名稱。To set the RowSourceType property to a user-defined function, enter the name of the function.

當您有並不會改變的值數目有限時,您可以將 RowSourceType 屬性設定為 Value List,然後輸入所組成的清單中的 RowSource 屬性的值。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.

當您建立使用者定義的函數來插入清單方塊或下拉式方塊的項目時,Access 就會呼叫該函數便會重複替換若要取得所需的資訊。When you create a user-defined function to insert items into a list box or combo box, Access calls the function repeatedly to get the information it needs. 使用者定義的RowSourceType函數必須寫入非常特定的函數格式User-defined RowSourceType functions must be written in a very specific function format.

範例Example

下列範例會將下拉式方塊的 RowSourceType 屬性設定為資料表/查詢],並會將 RowSource 屬性設定為名為 EmployeeList 的查詢。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"

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.