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

Last reviewed: August 29, 1997
Article ID: Q165629
The information in this article applies to:

  - Microsoft Access 97

SUMMARY

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

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 Technical Support engineers 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:

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

  2. Set the Navigation property of the Form to No.

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

  4. Use Notepad or another text editor to open the file that contains the characters "alx." You should see code similar to the following:

          <SCRIPT LANGUAGE=VBScript>
          <!--
          Dim rgszCtrls(6,2)
          Dim cMaxCtrls
          cMaxCtrls = 6
    
          Sub AddCtrlToList(szCtrl, szCtrlSrc)
              Dim i
              for i = 1 to cMaxCtrls
                  if rgszCtrls(i, 1) = szCtrl Then Exit Sub
                  if rgszCtrls(i, 1) = "" Then
                      rgszCtrls(i, 1) = szCtrl
                      rgszCtrls(i, 2) = szCtrlSrc
                      Exit Sub
                   End If
               next
           End Sub
    
    

  5. Add the following three Sub procedures to the code just before the line that reads </SCRIPT>.

    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
    
    

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

  7. Close and save the file.

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

REFERENCES

For more information about what can be exported to ASP format, search the Help Index for "ASP files," and then view the topic "Using Supported and unsupported form controls for dynamic ASP format," or ask the Microsoft Access 97 Office Assistant.

Keywords          : kbinterop IntAsp
Version           : 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.