Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Find a Record from a Drop-down List in a Data Access Page


View products that this article applies to.

This article was previously published under Q247823
Moderate: Requires basic macro, coding, and interoperability skills.

For a Microsoft 2002 version of this article, see 285353 (http://support.microsoft.com/kb/285353/EN-US/ ) .

↑ Back to the top


Summary

This article shows you how to find a record in a data access page based on an entry that you select from a drop-down list.

↑ Back to the top


More information

To create the data access page and the appropriate script to find a selected record, follow these steps:
  1. Open the sample database Northwind.mdb.
  2. In the Database window, click Pages under Objects, and then double-click Create data access page by using wizard.
  3. Under Tables/Queries, click the arrow, and then click Table: Customers in the list.
  4. Click >> to move all the fields from the Available Fields list to the Selected Fields list.
  5. Click Finish.
  6. In the toolbox, click Dropdown List, and then click anywhere on the page to add the Dropdown List control.
  7. Set the following properties for the Dropdown List control:
    ID: CustID
    ListRowSource: Table: Customers
    ListBoundField: CustomerID
  8. Right-click anywhere on the page, and then click Microsoft Script Editor on the shortcut menu to open the HTML source.
  9. On the View menu, point to Other Windows, and then click Script Outline. This places the focus in the Script Outline window pane, at the top-most node that is labeled Client Objects & Events. Expand Client Objects & Events, expand CustID, and then double-click the onchange event.
  10. Insert the following script:
    <SCRIPT LANGUAGE=vbscript FOR=CustID EVENT=onchange>
    <!--
        Dim rs
        Set rs = MSODSC.DefaultRecordset
        rs.Find "[CustomerID] = '" & document.all.item("CustID").value & "'", 0, 1, 1
    
        '0 = Skip zero records before starting the search.
        '1 = Search in a forward direction.
        '1 = Always begin the search with the first record in the recordset. 
    -->
    </SCRIPT>
    					
    NOTE: To search for numeric data, change the command line in the script as follows:
          rs.Find "[CustomerID] = " & document.all.item("CustID").value
    					
  11. Save the page as Page1.htm, and then click Page View on the View menu.
  12. Click a value in the CustID drop-down list to move the data access page to that record.

↑ Back to the top


Keywords: KB247823, kbdapscript, kbdap, kbhowto

↑ Back to the top

Article Info
Article ID : 247823
Revision : 2
Created on : 6/28/2004
Published on : 6/28/2004
Exists online : False
Views : 281