IT tutorials
 
Office
 

Microsoft Access 2010 : Maintain Data Integrity (part 3) - Restricting the Format of Data

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Product Key Free : Microsoft Office 2019 – Serial Number
4/27/2013 9:16:39 PM

3. Restricting the Format of Data

Two properties control the format of information in database tables: the Format property and the Input Mask property. Both properties affect how information is displayed after it has been entered in a table, but the Input Mask property also serves an important function during data entry. As its name implies, an input mask allows anyone entering new records to see at a glance the format required and how long the entry should be.


You can use the Input Mask property to control how data is entered in Text, Number, Date/Time, and Currency fields. For Text and Date/Time fields, an Input Mask wizard is available to help you apply several common, predefined masks. For Number and Currency fields, you have to know how to create a mask from scratch.

The Input Mask property has three sections, separated by semicolons. For example, the following mask is for a telephone number:

!\(000”) “000\-0000;1;#

The first section contains characters that are used as placeholders for the information to be typed, as well as characters such as parentheses and hyphens. Together, all these characters control the appearance of the entry. The following table explains the purpose of the most common input mask characters.

Character

Description

0

Required digit (0 through 9).

9

Optional digit or space.

#

Optional digit or space; blank positions are converted to spaces; plus and minus signs are allowed.

L

Required letter (A through Z).

?

Optional letter (A through Z).

A

Required letter or digit.

a

Optional letter or digit.

&

Required character (any kind) or a space.

C

Optional character (any kind) or a space.

<

All characters that follow are converted to lowercase.

>

All characters that follow are converted to uppercase.

!

Characters typed into the mask fill it from left to right. You can include the exclamation point anywhere in the input mask.

\

Character that follows is displayed as a literal character.

"any text"

Characters enclosed in double quotation marks are treated as literal characters.

Password

Creates a password entry box. Any character typed in the box is stored as the character but displayed as an asterisk (*).

Any characters not included in this list are displayed the way you type them and are known as literal characters. If you want to use one of the special characters in this list as a literal character, precede it with the (backslash) character.

The second and third sections of the input mask are optional. Including a 1 in the second section (or leaving it blank) tells Access to store only the characters entered; including a 0 tells it to store both the characters entered and the literal characters. Entering a character in the third section causes Access to display that character as the placeholder for each of the characters to be typed; leaving it blank causes Access to display an underscore as the placeholder.

The input mask !\(000”) “000\-0000;1;# creates this display in a field in either a table or a form:

(###) ###-####

In this example, the 0s in the first part of the mask restrict the entry to 10 digits—no more and no less. The database user does not enter the literal characters—the parentheses, space, and hyphen. The 1 in the second part tells Access not to store the literal characters; it should store only the 10 digits. The # sign in the third part tells Access to use that character as the placeholder for the required 10 digits.

Tip

An input mask can contain text as well as placeholders for the data to be entered. For example, if you type The number is in front of the telephone number input mask, the default entry for the field is The number is (###) ###-####. The numbers you type still replace the # placeholders, not the text. The Field Size property does not apply to the literal characters in the mask, so if this property is set to 15, the entry will not be truncated even though the number of displayed characters (including spaces) is 28.

In this exercise, you’ll use the Input Mask wizard to apply a predefined input mask for a telephone number to a Text field. Then you’ll modify the input mask to display the telephone number in a slightly different way. Finally, in another field you’ll create a custom mask that displays a text entry with an initial capital letter, no matter how it is actually typed.

Set Up

You need the GardenCompany06 database you worked with in the preceding exercise to complete this exercise. Open the GardenCompany06 database, and display the FieldTest table in Design view. Then follow the steps.

  1. Click the row selector for the fText field, and on the Design contextual tab, in the Tools group, click the Insert Rows button.

    image with no caption
  2. Add a new field named fPhone that is assigned the Text data type. Then save the table.

  3. With the fPhone field still selected, in the Field Properties area, click anywhere in the Input Mask property.

  4. Click the Ellipsis button to the right of the property, and save the table when prompted.

    image with no caption

    The Input Mask wizard displays its first page.

    Set Up

    You can click the Try It box to see how the mask will look and then type a number to see how the mask behaves.

  5. With Phone Number selected in the Input Mask list, click Next.

    The second page of the wizard is displayed.

    Set Up

    You can change the structure of the input mask and the placeholder character that will indicate what to type.

    The barely visible exclamation point at the left end of the mask causes Access to fill the mask from left to right with whatever is typed. The parentheses and hyphen are characters that Access will insert in the specified places. The nines represent optional digits, and the zeros represent required digits. This allows you to enter a telephone number either with or without an area code.

    Tip

    Because Access fills the mask from left to right, you would have to press the Right Arrow key to move the insertion point past the first three placeholders to enter a telephone number without an area code.

  6. Change 999 to 000 to require an area code. Then display the Placeholder character list, click #, and click Next.

    On the third page of the wizard, you specify whether you want to store the symbols with the data. (The symbols take up space, meaning that your database will be larger.)

    Tip

    If you store the symbols, they will always be included when the data is displayed in tables, forms, and reports.

  7. Accept the default selection—to store the data without the symbols—by clicking Finish.

    (Clicking Next simply displays a page announcing that the wizard has all the information it needs to create the mask.) Access closes the wizard.

    Tip

    The edited mask is inserted into the Input Mask property.

  8. Press Enter to accept the mask.

    Access changes the format of the mask to !\(000”) “000\-0000;;#. Notice the two semicolons that separate the mask into its three sections. Because you told Access to store data without the symbols, nothing is displayed in the second section of the mask. Notice also that Access added double quotation marks to ensure that the closing parenthesis and following space are treated as literal characters.

  9. Save the table, and then switch to Datasheet view.

  10. Click the ID field in the first record, and press the Tab key to move to the fPhone field. Then type a series of numbers to see how the mask works.

    Access formats the first 10 numbers you enter as a telephone number. If you type more than 10, Access ignores the additional digits. If you type fewer than 10 and then press Tab or Enter, Access warns that your entry doesn’t match the input mask.

    Tip

    The input mask requires 10, and only 10, digits.

    Now let’s see how an input mask can be used to control the display of data entries.

  11. Switch to Design view, and click anywhere in the fText field.

  12. In the Field Properties area, click the Input Mask property, type the following, and then press Enter:

    >L<???????????????? (16 question marks)

    Tip

    When you press Enter, the Property Update Options button appears. Clicking this button displays a list of options. In this case, the only options are to apply the input mask everywhere fText is used (which is called propagating the property), and to display Access Help to find out more about this task. This button disappears when you edit any other property or change to a different field, so you can ignore it.

    The greater than symbol (>) forces all following text to be uppercase. The L requires a letter. The less than symbol (<) forces all following text to be lowercase. Each question mark allows any letter or no letter. The total number of characters (17) is one fewer than the maximum number allowed in the field by this field’s Field Size property.

    Tip

    The Field Size setting must be greater than the maximum number of characters allowed by the mask.

  13. Save your changes to the table, and switch back to Datasheet view.

  14. Delete the current entry in the fText field, type smith, and press Tab.

  15. Replace the entry with SMITH, and then McDonald.

    Regardless of how you type the name, only its first letter is capitalized.

    Tip

    You can create custom input masks and have the Input Mask wizard store them for future use. On the wizard’s first page, click Edit List, and in the record navigation bar of the Customize Input Mask Wizard dialog box, click the New Record button. Then enter the information for the custom mask, and click Close.

Clean Up

Close the FieldTest table. Retain the GardenCompany06 database for use in later exercises.

Creating Custom Formats

You can construct custom Format properties to control the display of Text fields in much the same way you construct input masks. The following table describes the characters that are available.

Character

Description

@

Required character (can be blank).

&

Optional character.

!

Characters typed into the placeholder string fill it from left to right. You can include the exclamation point anywhere in the string.

<

All characters that follow are converted to lowercase.

>

All characters that follow are converted to uppercase.

*

Character that follows becomes a fill character.

\

Character that follows is displayed as a literal character.

"any text"

Characters enclosed in double quotation marks are treated as literal characters.

[color]

Applies a color to all characters in a section of the format. Can be black, blue, cyan, magenta, red, yellow, or white.

Tip

Blank spaces; plus (+), minus (-), and financial symbols ($, £, ¥); and parentheses are recognized as literal characters without double quotation marks.

To build a custom format:

  1. With the table open in Design view, select the field you want to apply the custom format to.

  2. In the Field Properties pane, in the Format box, type the format.

  3. Switch to Datasheet view, saving the table.

Any existing data will be displayed according to the format. New data you enter will conform to the format when you leave the field. As an example, consider the following format:

@”.com”;"no link"[red]

This format specifies two customizations separated by a semicolon. The part before the semicolon specifies what Access should do if characters are entered—in this case, append .com; and the part after the semicolon specifies what Access should do if the field is empty—in this case, display no link in red.

 
Others
 
- Microsoft Access 2010 : Maintain Data Integrity (part 2) - Restricting the Amount of Data
- Microsoft Access 2010 : Maintain Data Integrity (part 1) - Restricting the Type of Data
- Microsoft Project and the Project Management Domain : Using Microsoft Project with Methodologies and Life Cycles
- Microsoft Project and the Project Management Domain : Exploring Project Management Industry Standards
- Microsoft OneNote 2010 : Formatting Text (part 2) - Inserting Symbols and Special Characters, Copying and Applying Formatting with the Format Painter
- Microsoft OneNote 2010 : Formatting Text (part 1) - Setting the Default Font, Changing Basic Text Formatting, Using the Styles Gallery
- Microsoft Visio 2010 : Managing and Styling Pages (part 3) - Controlling Page Size and Orientation, Setting Page Scales
- Microsoft Visio 2010 : Managing and Styling Pages (part 2) - Working with Background Pages, Inserting Backgrounds, Titles, and Borders
- Microsoft Visio 2010 : Managing and Styling Pages (part 1) - Inserting Pages
- Microsoft PowerPoint 2010 : Incorporating Motion Video - Specifying Playback Options
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us