This article was previously published under Q163334
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Moderate: Requires basic macro, coding, and interoperability skills.
When you use an Active Server Pages (ASP) form to add or modify data in aMicrosoft Access database, if you type the percent (%), plus (+) or caret(^) symbols on the form, those characters may not translate correctly inthe database. This article discusses how to modify your ASP form to enableyou to use those characters.
NOTE: This article contains information about editing ASP files. Theinformation is provided as is. Microsoft Access Product SupportProfessionals do not support customizing your ASP files.
When you enter data in an ASP form and commit it, some special charactersare interpreted at the Web server as part of the VBScript code thatexecutes in the ASP file. When this happens, you may not see the correctcharacters in your database because the server tries to intercept them andprocess them. If you want to commit those characters to your database astheir keyboard equivalents, you must create a function in the ASP filethat translates them into their hexadecimal escape sequences.
When Microsoft Access 97 creates ASP files, it automatically creates aVBScript function in the file that translates most special characters backto their keyboard equivalents, such as the number sign (#) and theampersand (&). If you want to use percent, plus or caret symbols, you mustmodify the translation function to include those characters as well.
Each form that you export to ASP format creates at least two files:<FormName>.asp and <FormName>alx.asp. The "alx" file contains thetranslation function you need to modify. The following example shows youhow to create and modify an ASP file to accept the percent, plus and caretsymbols.
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.
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.
Use a text editor, such as Notepad, to open the Customersalx.asp form on your Web server.
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
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
Save the Customersalx.asp file and close it.
When you open Customers.asp in your Web program, you will be able to usepercent, plus, or caret symbols in the text boxes on the form in theCompany Name field for example, and those characters will appear correctlyin the Customers table of the Northwind database.