Microsoft KB Archive/299009

= ACC2002: Data Access Page Ignores Underlying Table's Input Mask =

Article ID: 299009

Article Last Modified on 9/27/2006

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q299009



For a Microsoft Access 2000 version of this article, see 200535.

Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access database (.mdb).



SYMPTOMS
When a control on a data access page is bound to a field in a table that has a valid input mask, the data access page ignores the input mask. In the data access page, you can enter and save values that do not conform to the input mask that is specified at the table level.



RESOLUTION
To work around this behavior, use the Microsoft Script Editor to insert script that creates an input mask on the data access page. For an example of how to do this, follow these steps:  Open the sample database Northwind.mdb. In the Database window, click Pages under Objects, and then click New. In the New Data Access page dialog box, click Page Wizard, click Customers in the Choose the table or query where the object's data comes from box, and then click OK. Select all the fields, and then click Finish. On the Tools menu, point to Macro, and then click Microsoft Script Editor.  On the Edit menu, point to Find and Replace, click Find, type the following in the Find what box, and click Find Next: class=MsoTextbox id=CustomerID </li>  Move the mouse pointer near the end of this line, which reads as follows: MsoTextAlign=&quot;General&quot;></TEXTAREA><SPAN </li>  Insert the mask into this portion of the line as follows: MsoTextAlign=&quot;General&quot; mask=&quot;LLLLL&quot;></TEXTAREA><SPAN </li>  Search for class=MsoTextbox id=PostalCode and insert the mask near the end of this line as follows: MsoTextAlign=&quot;General&quot; mask=&quot;#####-####&quot;></TEXTAREA><SPAN </li>  Search for class=MsoTextbox id=Phone and insert the mask near end of this line as follows: MsoTextAlign=&quot;General&quot; mask=&quot;###-###-####&quot;></TEXTAREA><SPAN </li>  Search for class=MsoTextbox id=Fax and insert the mask near the end of the line as follows: MsoTextAlign=&quot;General&quot; mask=&quot;###-###-####&quot;></TEXTAREA><SPAN </li> In the Objects drop-down list, click document.</li>  In the Events drop-down list node, click onkeypress. Note that new script is entered similar to: <SCRIPT LANGUAGE=vbscript FOR=document EVENT=onkeypress>

</SCRIPT> </li>  Replace this short portion of script with the following lengthy piece of script (if possible, copy and paste to avoid typographical errors): <SCRIPT id=clientEventHandlersJS language=javascript>

</SCRIPT>

<SCRIPT event=onkeypress for=document language=javascript> </SCRIPT>

<SCRIPT event=onblur for=CustomerID language=javascript> </SCRIPT>

<SCRIPT event=onblur for=Fax language=javascript> </SCRIPT>

<SCRIPT event=onblur for=Phone language=javascript> </SCRIPT>

<SCRIPT event=onbeforeupdate for=PostalCode language=javascript> </SCRIPT> </li> On the File menu, click Exit. If you are prompted to save the changes, click Yes, and then save the page with the default name that appears.</li> In Microsoft Access, click Page View on the View menu.</li> For the first record, enter alf in the CustomerID box, and press TAB to move to the next box. Note the message. Also note that you are not allowed to enter any numeric values.</li> Enter the full CustomerID of alfki, and then press TAB again. Note that the characters are all set to uppercase.</li> Experiment with the PostalCode, Phone, and Fax controls, and note the number and type of characters that you are allowed to enter into each control.</li></ol>

<div class="moreinformation_section">

Steps to Reproduce the Behavior

 * 1) In the sample database Northwind.mdb, open the Customers table in Design view.
 * 2) Note that the CustomerID field has an input mask of >LLLLL. The purpose of this mask is to force the user to enter exactly five characters for each ID and to set the five characters to uppercase. Close the table.
 * 3) In the Database window, click Pages under Objects, and then click New.
 * 4) In the New Data Access page dialog box, click Page Wizard, click Customers in the Choose the table or query where the object's data comes from box, and then click OK.
 * 5) Select all the fields, and then click Finish.
 * 6) On the View menu, click Page View.
 * 7) For the first record (that is, ALFKI), press BACKSPACE to delete KI, and then press TAB. Note that you can successfully move to the next record.
 * 8) Move back to the first record, and note that you can successfully change ALF to alfki (all lowercase letters).

Additional query words: prb inputmask masking not applied formatted

Keywords: kbdap kbprb KB299009

-

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

© Microsoft Corporation. All rights reserved.