ComboBox.Requery 方法 (Access)ComboBox.Requery method (Access)

Requery 方法更新基礎藉由重新查詢控制項資料來源的是作用中表單指定的控制項的資料。The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.



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


您可以使用此方法來確保表單或控制項顯示的是最新資料。You can use this method to ensure that a form or control displays the most recent data.

Requery 方法會執行下列其中一項動作:The Requery method does one of the following:

  • 傳回以表單或控制項為基礎的查詢。Reruns the query on which the form or control is based.
  • 顯示表單或控制項所根據的資料表上,任何新的或變更的記錄,或移除其中已刪除的記錄。Displays any new or changed records or removes deleted records from the table on which the form or control is based.
  • 更新顯示的記錄根據表單之 Filter 屬性的任何變更。Updates records displayed based on any changes to the Filter property of the form.

以查詢或資料表為基礎的控制項包括:Controls based on a query or table include:

  • 清單方塊和下拉式方塊。List boxes and combo boxes.
  • 子表單控制項 (子表單/子報表控制項)。Subform controls.
  • OLE 物件,例如圖表。OLE objects, such as charts.
  • 控制項 ControlSource 屬性設定值包含範圍聚合函數或 SQL 彙總函數。Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate functions.

如果您指定任何其他類型的控制項_expression_所指定的物件時,會重新查詢表單的記錄來源。If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

如果_expression_所指定的物件並未結合到資料表或查詢中的欄位, Requery方法會強制重新計算控制項。If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

如果您省略_運算式_所指定的物件, Requery方法重新查詢表單或控制項擁有焦點的基礎資料來源。If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. 如果控制項有焦點有記錄來源] 或 [資料列來源,它會重新查詢;否則,將只會重新整理控制項的資料。If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

如果子表單控制項有焦點,此方法會只重新查詢子表單的記錄來源,而不會重新查詢父表單。If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.


  • Requery 方法會更新在表單或控制項下方的資料,來反映自從上次重新查詢資料之後新增至記錄來源或從記錄來源中刪除的記錄。The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. Refresh方法會顯示對目前的記錄; 集所做的變更它不會反映記錄來源中的新的或已刪除記錄。The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. 指定的表單和它的控制項,只會重新繪製Repaint方法。The Repaint method simply repaints the specified form and its controls.
  • Requery 方法並不會釋放控制權給作業系統,以允許 Windows 繼續處理訊息。The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. 如果需要暫時釋放控制權給作業系統,請使用 DoEvents 函數。Use the DoEvents function if you need to relinquish temporary control to the operating system.
  • Requery方法會比 Requery 巨集指令。The Requery method is faster than the Requery action. 當您使用 Requery 巨集指令時,Microsoft Access 會關閉查詢並從資料庫重新載入。When you use the Requery action, Microsoft Access closes the query and reloads it from the database. 當您使用Requery方法時,Access 會傳回的查詢而關閉並將它重新載入。When you use the Requery method, Access reruns the query without closing and reloading it.


下列範例使用Requery方法來重新查詢 [ Employees ] 表單上 [ EmployeeList ] 清單方塊的資料。The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form.

Public Sub RequeryList() 
    Dim ctlCombo As Control 
    ' Return Control object pointing to a combo box. 
    Set ctlCombo = Forms!Employees!ReportsTo 
    ' Requery source of data for list box. 
End Sub

支援和意見反應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.