Sunday, June 3, 2018

Requery Macro Action

Requery Macro Action

You can use the Requery macro action in Access databases to update the data in a specified control on the active object by requerying the source of the control. If no control is specified, this action requeries the source of the object itself. Use this action to ensure that the active object or one of its controls displays the most current data.

Setting

The Requery macro action has the following argument.

Action argument

Description

Control Name

The name of the control you want to update. Enter the control name in the Control Name box in the macro design window. You should use only the name of the control, not the fully qualified identifier (such as Forms!formname!controlname). Leave this argument blank to requery the source of the active object. If the active object is a datasheet or a query result set, you must leave this argument blank.

Remarks

The Requery macro action does one of the following:

  • Reruns the query on which the control or object is based.

  • Displays any new or changed records, and removes any deleted records from the table on which the control or object is based.

Note: The Requery macro action does not affect the position of the record pointer.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts.

  • Controls containing domain aggregate functions, such as DSum.

If the specified control isn't based on a query or table, this action forces a recalculation of the control.

If you leave the Control Name argument blank, the Requery action has the same effect as pressing SHIFT+F9 when the object has the focus. If a subform control has the focus, this action requeries only the source of the subform (just as pressing SHIFT+F9 does).

Note: The Requery macro action requeries the source of the control or object. In contrast, the RepaintObject macro action repaints controls in the specified object but doesn't requery the database or display new records. The ShowAllRecords macro action not only requeries the active object, but it also removes any applied filters, which the Requery macro action doesn't do.

If you want to requery a control that isn't on the active object, you must use the Requery method in a Visual Basic for Applications (VBA) module, not the Requery macro action or its corresponding Requery method of the DoCmd object. The Requery method in VBA is faster than the Requery macro action or the DoCmd.Requery method. In addition, when you use the Requery macro action or the DoCmd.Requery method, Access closes the query and reloads it from the database, but when you use the Requery method, Access reruns the query without closing and reloading it. Note that the ActiveX Data Object (ADO) Requery method works the same way as the Access Requery method.

No comments:

Post a Comment