Microsoft KB Archive/306148

= ACC2002: How to Navigate to a Particular Record on a Data Access Page =

Article ID: 306148

Article Last Modified on 9/27/2006

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q306148



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

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



SUMMARY
On a Microsoft Access form, you can enter the record number in the navigation bar to move to a particular record. Data access pages do not have this feature. However, you can simulate this functionality on data access pages by using script to respond to a number that is typed in a text box.



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. 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.

 Start Microsoft Access. On the Help menu, point to Sample Databases, and then click Northwind Sample Database. On the Insert menu, click Page. In the New Data Access Page dialog box, click AutoPage: Columnar, click Orders in the Choose the table or query where the objects data comes from box, and then click OK. On the View menu, click Design View. If the toolbox is not visible, click Toolbox on the View menu.</li> Add a text box control to the page.</li> Right-click the text box, and then click Element Properties.</li> On the Other tab, change the Id property to txtNavRecord.</li> On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> Click txtNavRecord in the Client Objects & Events list.</li> Click onkeydown in the list of events.</li>  Type the following code in the event between the 'Trap the ENTER key. If window.event.keyCode = 13 Then 'Make sure the number entered is greater than zero. If txtNavRecord.value > 0 Then 'Move to the specified record. MSODSC.DefaultRecordset.AbsolutePosition = txtNavRecord.value 'Clear the text box. txtNavRecord.value = &quot;&quot; 'Suppress the Enter key to avoid moving 'to a new line in the text box. window.event.returnValue = False Else 'Clear the text box and suppress the Enter key. txtNavRecord.value = &quot;&quot; window.event.returnValue = False End If End If                   </li> Save the page, and then close the Microsoft Script Editor to return to the page in Design view.</li> On the View menu, click Page View.</li> Type the following numbers into the text box, and press ENTER after each number:

50

71

410

11

Note that the data access page moves to the specified record number after each entry.</li></ol>

Additional query words: inf dap

Keywords: kbhowto KB306148

-

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

© Microsoft Corporation. All rights reserved.