OFFXPDEV: Filter By Form Is Not Available in Run-Time Applications (306361)



The information in this article applies to:

  • Microsoft Office XP Developer
  • Microsoft Access 2002

This article was previously published under Q306361
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

For a Microsoft Office 2000 Developer Edition version of this article, see 262094.

SYMPTOMS

If you programmatically open a form in Filter-by-Form view in a Microsoft Access 2002 run-time application, you may receive the following error message:
Execution of this application has stopped due to a run-time error. The application can't continue and will be shut down.

CAUSE

The Filter-by-Form commands are not available in a Microsoft Access 2002 run-time application.

RESOLUTION

For additional information about simulating Filter-by-Form in a run-time application, click the article number below to view the article in the Microsoft Knowledge Base:

262099 ACC2000: Filter-by-Form Example for Run-Time Applications Available in the Download Center

Even though this example was created using Access 2000, the code still works in Access 2002.

MORE INFORMATION

Steps to Reproduce the Behavior

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. In the sample database Northwind.mdb, open the Customers form in Design view.
  2. Add a command button to the form.
  3. Change the Name property of the command button to btnFilter.
  4. Set the OnClick property of the command button to the following event procedure:
    Private Sub btnFilter_Click()
      DoCmd.RunCommand acCmdFilterByForm
    End Sub
    					
  5. Save the form, and then close it.
  6. On the Tools menu, click Startup.
  7. Under Display Form, click Customers in the list, and then click OK.
  8. Click Start, click Run, and then type the following command in the Open box.

    NOTE: In the following sample, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when you type this command.

    NOTE: If Microsoft Office is not installed in the default location of C:\Program Files\Microsoft Office\Office10\, change the following path to where Msaccess.exe is located on your computer:

    "C:\Program Files\Microsoft Office\Office10\Msaccess.exe" _
    "C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb" _
    /Runtime

  9. When the Customers form opens, click the command button that you created in step 2.

    Note that the Filter-by-Form view does not appear and that you receive the error message mentioned in the "Symptoms" section of this article.

Modification Type:MajorLast Reviewed:5/28/2003
Keywords:kbbug kberrmsg KB306361