控件方法 (Access)Control.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.

语法Syntax

表达式Requeryexpression.Requery

_表达式_一个代表**Control** 对象的变量。expression A variable that represents a Control object.

说明Remarks

可以使用此方法确保窗体或控件显示最新的数据。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.
  • 控件的 控件来源 属性设置包括域聚合函数或 SQL 聚合函数。Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate functions.

如果为_表达式_指定的对象指定任何其他类型的控件, 则重新查询窗体的记录源。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.

如果省略由 expression 指定的对象,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. 方法只是重新绘制指定的窗体及其控件。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.

示例Example

下面的示例使用requery方法来重新查询 "雇员" 窗体上的 " 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. 
    ctlCombo.Requery 
 
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.