Microsoft KB Archive/237377

= ACC2000: How to Use Server Filters on Data Access Pages Without a Web Server =

Article ID: 237377

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q237377



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

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

For a Microsoft Access 2002 version of this article, see 285162.



SUMMARY
This article demonstrates how to create script that filters a data access page by setting the ServerFilter property. You can use this script even when the page is not stored on a Web server.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following steps demonstrate how to create a page based on the Customers table. When you open the page or click the New Filter button, the script prompts you for a list of countries. The script then limits the number of records returned based on the countries that you entered. You can return all records by leaving the list empty.

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.

 Open the sample database Northwind.mdb. Create a new page in Design view. If the field list is not visible, on the View menu, click Field List. From the Customers table, drag the CustomerID, CompanyName, City, Region, and Country onto the page.  Add a command button to the page and set the following properties:   ID: cmdFilter Inner Text: New Filter  On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li>  On the HTML menu, point to Script Block, and then click Client. Type the following script: <SCRIPT language=vbscript>

</SCRIPT> </li>  Using the Script Outline, insert the following script for the DataPageComplete event of the MSODSC:IMPORTANT: When you create VBScript blocks for MSODSC events, you must add a parameter to the event name as follows:

<SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(oEventInfo)>

The <I>oEventInfo</I> parameter returns specific information about the event to the script. You must add this parameter, whether or not it will be used, because the script will not work without it.

<SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=DataPageComplete(oEventInfo)>

</SCRIPT> </li>  Using the Script Outline, insert the following script for the OnClick event of the cmdFilter button: <SCRIPT LANGUAGE=vbscript FOR=cmdFilter EVENT=onclick>

</SCRIPT> </li> Close the Microsoft Script Editor and save the page as dapSvrFilterEx.</li> On the View menu, click Page View.</li> In the dialog box, type Canada; Mexico; USA. Click OK. There should be approximately 21 records.</li></ol>

Additional query words: programmatically

Keywords: kbhowto kbdap kbdapscript KB237377

-

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

© Microsoft Corporation. All rights reserved.