Microsoft KB Archive/285353: Difference between revisions
m (Text replacement - ">" to ">") |
m (Text replacement - "&" to "&") |
||
Line 77: | Line 77: | ||
</div></li> | </div></li> | ||
<li>Right-click anywhere on the page, and then click '''Microsoft Script Editor''' on the shortcut menu to open the HTML source.</li> | <li>Right-click anywhere on the page, and then click '''Microsoft Script Editor''' on the shortcut menu to open the HTML source.</li> | ||
<li>In the '''Client Objects & | <li>In the '''Client Objects & Events''' dropdown list, click '''CustID''', and then click '''onchange''' in the '''Events''' dropdown list.</li> | ||
<li><p>Type or paste the following script:</p> | <li><p>Type or paste the following script:</p> | ||
<pre class="codesample"><SCRIPT LANGUAGE=vbscript FOR=CustID EVENT=onchange> | <pre class="codesample"><SCRIPT LANGUAGE=vbscript FOR=CustID EVENT=onchange> | ||
Line 83: | Line 83: | ||
Dim rs | Dim rs | ||
Set rs = MSODSC.DefaultRecordset | Set rs = MSODSC.DefaultRecordset | ||
rs.Find "[CustomerID] = '" & | rs.Find "[CustomerID] = '" & document.all.item("CustID").value & "'", 0, 1, 1 | ||
'0 = Skip zero records before starting the search. | '0 = Skip zero records before starting the search. | ||
Line 92: | Line 92: | ||
</pre> | </pre> | ||
<p>'''Note''' To search for numeric data, change the command line in the script as follows:</p> | <p>'''Note''' To search for numeric data, change the command line in the script as follows:</p> | ||
<pre class="codesample"> rs.Find "[CustomerID] = " & | <pre class="codesample"> rs.Find "[CustomerID] = " & document.all.item("CustID").value | ||
</pre></li> | </pre></li> | ||
<li>Save the page as Page1.htm, and then click '''Page View''' on the '''View''' menu.</li> | <li>Save the page as Page1.htm, and then click '''Page View''' on the '''View''' menu.</li> |
Latest revision as of 12:36, 21 July 2020
Article ID: 285353
Article Last Modified on 1/29/2007
APPLIES TO
- Microsoft Office Access 2003
- Microsoft Access 2002 Standard Edition
This article was previously published under Q285353
Moderate: Requires basic macro, coding, and interoperability skills.
For a Microsoft Access 2000 version of this article, see 247823.
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.
MORE INFORMATION
To create the data access page and the appropriate script to find a selected record, follow these steps:
- Open the sample database Northwind.mdb.
- In the Database window, click Pages under Objects, and then double-click Create data access page by using wizard.
- Under Tables/Queries, click the arrow, and then click Table: Customers in the list.
- Click the >> button to move all the fields from the Available Fields list to the Selected Fields list, and then click Finish.
- If the toolbox is not displayed, click Toolbox on the View menu.
- In the toolbox, click Dropdown List, and then click anywhere on the page to add the dropdown list control.
- Set the following properties for the dropdown list control:
ID: CustID
ListRowSource: Table: Customers
ListBoundField: CustomerID - Right-click anywhere on the page, and then click Microsoft Script Editor on the shortcut menu to open the HTML source.
- In the Client Objects & Events dropdown list, click CustID, and then click onchange in the Events dropdown list.
Type or paste 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
- Save the page as Page1.htm, and then click Page View on the View menu.
- Click a value in the CustID drop-down list to move the data access page to that record.
Additional query words: OfficeKBHowTo inf dap mod dhtml search move to ACC2002 reviewdocid
Keywords: kbscript kbprogramming kbdapscript kbhowto KB285353