Microsoft KB Archive/165629

= ACC97: How to Create Custom Navigation Buttons on an ASP Page =

Article ID: 165629

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q165629



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



SUMMARY
When you export a form from Microsoft Access 97 as an Active Server Page, and that form has custom buttons that move from one record to the next, the buttons will not work on your Active Server Page form. This happens because the Visual Basic code that performs the actions in Microsoft Access is not exported to your Active Server Page form.

There are two ways to have navigation buttons appear on your Active Server Page form:
 * Use the Microsoft Access built-in navigation buttons and set the Navigation property of the form to Yes.
 * Modify the VBScript for the Active Server Page form that you are exporting so that the code will allow you to move through your form as you click a button.



MORE INFORMATION
NOTE: This section contains information about editing ASP files and assumes that you are familiar with editing HTML files, Active Server Pages, and Visual Basic Scripting. Microsoft Access Product Support professionals do not support customization of any HTML, HTX, IDC, or ASP files.

This article demonstrates a method that creates custom navigation buttons that enable you to move through the form by modifying the VBScript for the Active Server Page file. To modify the VBScript for a particular form, follow these steps:   Create the form that you will be using as an Active Server Page and add the following command buttons to the form: Command Button: Name: MoveNextRecord Caption: MoveNextRecord

Command button: Name: MoveFirstRecord Caption: MoveFirstRecord

Command button: Name: MoveLastRecord Caption: MoveLastRecord  Set the Navigation property of the Form to No. Export the form to Active Server Page format and note the folder to which the file is exported. There should be two files in this folder that are associated with your Active Server Page. One of the files will contain the characters "alx" (without the quotation marks).  Use Notepad or another text editor to open the file that contains the characters "alx." You should see code similar to the following:    Add the following three Sub procedures to the code just before the line that reads .

NOTE: In the following sample code, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code. Sub FirstRecord_MoveFirstRecord_Click

Window.Location.Href = "/scripts/formname.asp?nav_btn=nav_btn_MoveFirstRecord&" _ & GetCtrlQueryString

End Sub

Sub NextRecord_MoveNextRecord_Click

Window.Location.Href = "/scripts/formname.asp?nav_btn=nav_btn__MoveNextRecord&" _ & GetCtrlQueryString

End Sub

Sub LastRecord_MoveLastRecord_Click

Window.Location.Href = "/scripts/formname.asp?nav_btn=nav_btn__MoveLastRecord&" _ & GetCtrlQueryString

End Sub </li>  Modify the OBJECT ID's for the above controls in the </SCRIPT> section and replace the names as follows: FirstRecord = FirstRecord_MoveFirstRecord. NextRecord = NextRecord_MoveNextRecord. LastRecord = LastRecord_MoveLastRecord. </li> Close and save the file.</li> Open your Web browser and your Active Server Page form. Click one of the custom command buttons. The buttons should now enable you to move through the pages.</li></ol>

<div class="references_section">