Microsoft KB Archive/163334

= ACC97: How to Use Percent, Plus, and Caret Symbols in ASP Forms =

Article ID: 163334

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q163334



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



SUMMARY
When you use an Active Server Pages (ASP) form to add or modify data in a Microsoft Access database, if you type the percent (%), plus (+) or caret (^) symbols on the form, those characters may not translate correctly in the database. This article discusses how to modify your ASP form to enable you to use those characters.

NOTE: This article contains information about editing ASP files. The information is provided as is. Microsoft Access Product Support Professionals do not support customizing your ASP files.



MORE INFORMATION
When you enter data in an ASP form and commit it, some special characters are interpreted at the Web server as part of the VBScript code that executes in the ASP file. When this happens, you may not see the correct characters in your database because the server tries to intercept them and process them. If you want to commit those characters to your database as their keyboard equivalents, you must create a function in the ASP file that translates them into their hexadecimal escape sequences.

When Microsoft Access 97 creates ASP files, it automatically creates a VBScript function in the file that translates most special characters back to their keyboard equivalents, such as the number sign (#) and the ampersand (&). If you want to use percent, plus or caret symbols, you must modify the translation function to include those characters as well.

Each form that you export to ASP format creates at least two files: .asp and alx.asp. The "alx" file contains the translation function you need to modify. The following example shows you how to create and modify an ASP file to accept the percent, plus and caret symbols.  Start Microsoft Access and open the sample database Northwind.mdb. Select the Customers form in the Database window. On the File menu, click Save As/Export. In the Save As dialog box, click "To an External File or Database," and then click OK. In the "Save Form 'Customers' In" dialog box, select Microsoft Active Server Pages (*.asp) in the Save As Type box, and select a folder on your Web server where you have Execute permission in the Save In box. Click Export.</li> In the Microsoft Active Server Pages Output Options dialog box, type the name of a System DSN on your Web server that connects to the Northwind sample database in the Data Source Name box, and type the uniform resource locator (URL) for the folder on your server where the ASP forms will reside in the Server URL box. Click OK.

Two files will be created on your Web server computer: Customers.asp and Customersalx.asp.</li> Use a text editor, such as Notepad, to open the Customersalx.asp form on your Web server.</li>  Locate the MakeHTMLValue function in the file, which looks as follows: Function MakeHTMLValue(szVal) Dim i        Dim szRet for i = 1 to Len(szVal) ch = Mid(szVal, i, 1) if ch = " " Then szRet = szRet & "%20" elseif ch = "&" Then szRet = szRet & "%26" elseif ch = "#" Then szRet = szRet & "%23" elseif ch = """" Then szRet = szRet & "%22" elseif ch = ";" Then szRet = szRet & "%3B" elseif ch = ":" Then szRet = szRet & "%3A" elseif ch = "'" Then szRet = szRet & "%27" else szRet = szRet & Mid(szVal, i, 1) end if        next MakeHTMLValue = szRet End Function </li>  Modify the MakeHTMLValue function to include the escape sequences for the percent, plus, and caret symbols so that it looks as follows: Function MakeHTMLValue(szVal) Dim i        Dim szRet for i = 1 to Len(szVal) ch = Mid(szVal, i, 1) if ch = " " Then szRet = szRet & "%20" elseif ch = "&" Then szRet = szRet & "%26" elseif ch = "#" Then szRet = szRet & "%23" elseif ch = """" Then szRet = szRet & "%22" elseif ch = ";" Then szRet = szRet & "%3B" elseif ch = ":" Then szRet = szRet & "%3A" elseif ch = "'" Then szRet = szRet & "%27" elseif ch = "%" Then szRet = szRet & "%25" elseif ch = "+" Then szRet = szRet & "%2B" elseif ch = "^" Then szRet = szRet & "%5E" else szRet = szRet & Mid(szVal, i, 1) end if        next MakeHTMLValue = szRet End Function </li> Save the Customersalx.asp file and close it.</li></ol>

When you open Customers.asp in your Web program, you will be able to use percent, plus, or caret symbols in the text boxes on the form in the Company Name field for example, and those characters will appear correctly in the Customers table of the Northwind database.

Additional query words: reserved map xlate frontpage frontpg

Keywords: kbhowto kbinterop kbprogramming KB163334

-

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

© Microsoft Corporation. All rights reserved.