ACC2000: Error Previewing Subreports That Call Filter Macro

ID: Q209482


The information in this article applies to:

Moderate: Requires basic macro, coding, and interoperability skills.


SYMPTOMS

When you print a form or a report that contains a subform/subreport that calls an ApplyFilter macro action in its OnOpen event, you receive the following error message:

The action or method is invalid because the form or report isn't bound
to a table or query.
Even if you do not receive this error message, you see that the ApplyFilter action has not been carried out.


CAUSE

When printing, Microsoft Access erroneously tries to apply the filter that is run from the macro to the outermost (main) report/form, rather than to the subreport/subform.

The error occurs because the main report/form does not contain a RecordSource property setting to perform the ApplyFilter action against.


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

Steps to Reproduce Problem

  1. Start Microsoft Access and open the sample database Northwind.mdb.


  2. Create a new macro that carries out an ApplyFilter action. Type the following criteria in the Where Condition:


  3. [CustomerID]="BERGS"
  4. Close and save the macro as MyFilter.


  5. In the Database window, click Tables under Objects, and then select the Orders table.


  6. On the Insert menu, click AutoReport.


  7. On the File menu, click Save As, and save the report as MySubReport.


  8. Set the OnOpen property of the MySubReport report to the MyFilter macro.


  9. Close and save the changes to the MySubReport report.


  10. Open a new report not based on any table or query in Design View.


  11. Drag the MySubReport report to the detail section of this new report.


  12. Save this new report as MyMainReport and preview the report. Note that you receive the following error message:


  13. The action or method is invalid because the form or report isn't bound
    to a table or query.
  14. Change the RecordSource property of the MyMainReport report to point to the Customers table and add the CustomerID field to the detail section of the MyMainReport report.


  15. Save the change and preview the MyMainReport report again. Note that the error message no longer occurs; however, neither the subreport nor the main report has been filtered.


Additional query words: subreports reports subforms


Keywords          : kberrmsg kbusage kbdta RptSub 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: May 13, 1999