ACC2000: Error with Requery Macro Action to Requery a Control on a Subform (279028)
The information in this article applies to:
This article was previously published under Q279028 Moderate: Requires basic macro, coding, and interoperability skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
SYMPTOMS
When you use the Requery action in a Microsoft Access macro to requery a control on a subform, you receive the following error message:
You can't use the ApplyFilter action on this window.- You tried to use the ApplyFilter action or method, but you didn't apply the filter to a table, query, form, or report.
- You may have applied the filter to a form, but the form wasn't open in Form or Datasheet view.
- You may have applied the filter to a report but didn't use the ApplyFilter action in a macro specified by the OnOpen property setting.
Use the SelectObject action or method to select the table, query, form, or report before applying the filter.
RESOLUTION
To resolve this behavior, use one of the following methods.
Method 1: Use the RunCommand Macro Action Instead of the Requery Action- Open the macro in Design View.
- Change the Requery action to RunCommand.
- Set the Command action argument to Run.
- Close the macro, and then click Yes when you are prompted to save the changes.
Method 2: Use Visual Basic for Applications Code to Requery the Control on the Subform- Remove the call that is made to the macro. For example, if you have a command button that calls the macro from its OnClick property, remove this macro name from the OnClick property.
- Add Visual Basic for Applications code to requery the control on the subform. For example, if you are using a command button to requery the subform, click the Build button (the button with the three dots) next to the OnClick property of the command button, click Code Builder, and then click OK.
- Enter the following code for the button's Click procedure
Forms!<FormName>!<SubformControl>.Form!<ControlName>.SetFocus
Me.Requery
where <FormName> is the name of the main form, <SubformControl> is the name of the subform object that appears on the main form, and <ControlName> is the name of the control on the subform. - On the Debug menu, click Compile <name>, and then close the Visual Basic Editor to return and run your form.
REFERENCESFor more information about the RunCommand macro action, click Microsoft Access Help on the
Help menu, type runcommand in the Office Assistant or
the Answer Wizard, and then click Search to view the topics
returned.
For more information about getting help on Visual Basic for Applications, click Microsoft Visual Basic Help on the
Help menu, type vba in the Office Assistant or
the Answer Wizard, and then click Search to view the topics
returned.
For more information about the SetFocus method, click Microsoft Visual Basic Help on the
Help menu, type setfocus in the Office Assistant or
the Answer Wizard, and then click Search to view the topics
returned.
For more information about the Requery method, click Microsoft Visual Basic Help on the
Help menu, type requery in the Office Assistant or
the Answer Wizard, and then click Search to view the topics
returned.
Modification Type: | Major | Last Reviewed: | 6/25/2004 |
---|
Keywords: | kbbug kbpending KB279028 |
---|
|