Microsoft KB Archive/200535

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

Article ID: 200535

Article Last Modified on 7/16/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q200535



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

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

For a Microsoft Access 2002 version of this article, see 299009.



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, click Find and Replace, type the following in the Find box, and then click Find: title=CustomerID </li>  Move the mouse pointer near the end of this line. Note that there is HTML syntax similar to: title=CustomerID></TEXTAREA> </li>  Insert the mask into this portion of the line as follows: title=CustomerID mask="LLLLL"></TEXTAREA> </li>  Now search for: title=PostalCode and insert the mask near the end of this line as follows: title=PostalCode mask="#####-####"></TEXTAREA> </li>  Search for: title=Phone and insert the mask near end of this line as follows: title=Phone mask="###-###-####"></TEXTAREA> </li>  Finally, search for: title=Fax and insert the mask near the end of the line as follows: title=Fax mask="###-###-####"></TEXTAREA> </li> On the View menu, point to Other Windows, and then click Script Outline.</li>  In the Script Outline window, expand the Client Objects & Events node, expand the document node, and then double-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, and then click Yes to save the changes if you are prompted.</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 letters. 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 KB200535

-

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

© Microsoft Corporation. All rights reserved.