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

ID: Q165629


The information in this article applies to:
  • Microsoft Access 97

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:

  1. Create the form that you will be using as an Active Server Page and add the following command buttons to the form:


  2. 
       Command Button:
          Name: MoveNextRecord
          Caption: MoveNextRecord
    
       Command button:
          Name: MoveFirstRecord
          Caption: MoveFirstRecord
    
       Command button:
          Name: MoveLastRecord
          Caption: MoveLastRecord 
  3. Set the Navigation property of the Form to No.


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


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


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


  8. 
          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 
  9. Modify the OBJECT ID's for the above controls in the </SCRIPT> section and replace the names as follows:


  10. 
           FirstRecord = FirstRecord_MoveFirstRecord.
           NextRecord = NextRecord_MoveNextRecord.
           LastRecord = LastRecord_MoveLastRecord. 
  11. Close and save the file.


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

Additional query words:

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


Last Reviewed: October 11, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.