Microsoft KB Archive/296049

= ACC2002: OpenForm and OpenReport WHERE Clauses Are Ignored When You Use Server Filter =

Article ID: 296049

Article Last Modified on 9/25/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q296049



Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access project (.adp).



SYMPTOMS
When you use a WHERE clause with the OpenForm and OpenReport methods and actions, the WHERE clause will be ignored if a server filter has been set on the form or report.



CAUSE
If a server filter exists, it will be used to query SQL Server instead of the WHERE clause in the OpenForm or OpenReport command.



RESOLUTION
Remove the ServerFilter property setting in Design view, and then save the form or the report. When the form or report is opened, it will reflect the records that are specified in the WHERE clause in the OpenForm or OpenReport methods or actions.



MORE INFORMATION
A common technique to synchronize two forms in order to show related data is to specify a WHERE clause in the OpenForm command. The Command Button Wizard creates an OpenForm statement when you select the option Open the form and find specific data to display.

However, if the form being opened already has a server filter specified, it indicates to Access that all query processing should be done on the server and to ignore the WHERE clause in the OpenForm command.

Steps to Reproduce the Behavior
 Open the sample project NorthwindCS.adp, and then open the Orders form in Design view. Add the following setting to the ServerFilter property of the Orders form, and then save the form:

[Region] = 'WA'

 Open the form, and note that the server filter is applied. Only the records for the region 'WA' are displayed. Close and then save the changes to the form. Open the Customers form in Design view, and then use the Command Button Wizard to add a command button to open the Orders form. Click the option to Open the form and find specific data to display.</li> Select to match on CustomerID, accept the default options, and then save the changes. The Command Button Wizard will automatically write the correct OpenForm command using the CustomerID as the WHERE clause to show matching records.</li> Open the Customer form, and note which customer is being displayed; then, click the button to show that customer's matching orders.</li></ol>

Note that instead of showing the matching orders for CustomerID, the server filter is applied, and the orders for the specified region are displayed. Had the ServerFilter property not been set, the correct matching orders would have been displayed.

Additional query words: pra prb ServerFilter

Keywords: kbprb KB296049

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.