Setting Control Properties


Access 2007 gives you many properties for each control to allow you to customize the way your form works. These properties affect formatting, the presence or absence of scroll bars, the enabling or locking of records, the tab order, and more.

Formatting Properties

In the property sheet for each text box, combo box, and list box are three properties that you can set to determine how Access displays the data in the form. These properties are Format, Decimal Places, and Input Mask, as shown in Figure 12–43. (The Input Mask property is listed farther down the list on the All tab of the property sheet and isn’t shown in Figure 12–43.)

image from book
Figure 12–43: You can select a format from the list of format settings for the BirthDate control, which uses the Date/Time data type.

Inside Out-Always Use Four-Digit Year Values 

We recommended earlier that you change the date display in the Regional And Language Options section of Windows Control Panel to display a four-digit year. Although Access adjusts the century digits automatically when you enter two-digit years, you will avoid confusion about the actual value stored after the year 1999 if you always display the full year. All samples you see in this book using the Short Date format show four-digit years because we changed the settings on our computers. If your computer is set to display a two-digit year, you will see a different result everywhere we used the Short Date format.

For details on the Input Mask property, see Chapter 4, “Creating Your Database and Tables.” For details on dynamically changing format properties (also called conditional formatting) based on the value currently displayed, see Chapter 13, “Advanced Form Design.”

Access copies these properties from the definition of the fields in the underlying table. If you haven’t specified a Format property in the field definition, Access sets a default Format property for the control, depending on the data type of the field bound to the control. In the control’s property sheet, you can customize the appearance of the data on your form by selecting a format setting from the Format property’s list or by entering a custom set of formatting characters. The following sections present the format settings and formatting characters available for each data type.

Specifying a Format for Numbers and Currency

If you don’t specify a Format property setting for a control that displays a number or a currency value, Access displays numbers in the General Number format and currency in the Currency format. You can choose from seven Format property settings, as shown in Table 12–1.

Table 12–1: Format Property Settings for Number and Currency Data Types
Open table as spreadsheet

Format

Description

General Number

Displays numbers as entered with up to 11 significant digits. If a number contains more than 11 significant digits or the control you are using to display the value is not wide enough to show all digits, Access first rounds the displayed number and then uses scientific (exponential) notation for very large or very small numbers (more than 10 digits to the right or to the left of the decimal point).

Currency

Displays numeric data according to the Currency setting in the Regional And Language Options section of Windows Control Panel. In the U.S. layout, Access uses a leading dollar sign, maintains two decimal places (rounded), and encloses negative numbers in parentheses.

Euro

Displays numeric data according to your Currency setting, but always uses a leading euro symbol.

Fixed

Displays numbers without thousands separators and with two decimal places. The number displayed is rounded if the underlying value contains more than two decimal places.

Standard

Displays numbers with thousands separators and with two decimal places. The number displayed is rounded if the underlying value contains more than two decimal places.

Percent

Multiplies the value by 100, displays two decimal places, and adds a trailing percent sign. The number displayed is rounded if the underlying value contains more than four decimal places.

Scientific

Displays numbers in scientific (exponential) notation.

You can also create a custom format. You can specify a different display format for Access to use (depending on whether the numeric value is positive, negative, 0, or Null) by providing up to four format specifications in the Format property. You must separate the specifications by semicolons. When you enter two specifications, Access uses the first for all nonnegative numbers and the second for negative numbers. When you provide three specifications, Access uses the third specification to display numbers with a value of 0. Use the fourth specification to indicate how you want Null values handled.

To create a custom number format, use the formatting characters shown in Table 12–2. Notice that you can include text strings in the format and specify a color to use.

Table 12–2: Formatting Characters for Number and Currency Data Types
Open table as spreadsheet

Character

Usage

Decimal separator

Use to indicate where you want Access to place the decimal point. Use the decimal separator defined in the Regional And Language Options section of Windows Control Panel. In the English (U.S.) layout, the separator is a period (.).

Thousands separator

Use to indicate placement of the thousands separator character that is defined in the Regional And Language Options section of Windows Control Panel. In the English (U.S.) layout, the separator is a comma (,). When the position immediately to the left of the separator is # and no digit exists in that position, the thousands separator also is not displayed.

0.

Use this placeholder character to indicate digit display. If no digit exists in the number in this position, Access displays 0.

#

Use this placeholder character to indicate digit display. If no digit exists in the number in this position, Access displays a blank space.

+$ () or a blank space

Use these characters anywhere you want in your format string.

“text”

Use double quotation marks to embed any text you want displayed.

\

Use to always display the character immediately following (the same as including a single character in double quotation marks).

!

Use to force left alignment. You cannot use any other digit placeholder characters (0 or #) when you force left alignment; however, you can use character placeholders as shown in Table 12–3 on page 655.

*

Use to designate the immediately following character as the fill character. Access usually displays formatted numeric data rightaligned and filled with blank spaces to the left. You can embed the fill character anywhere in your format string. For example, you can specify a format string for a Currency value as follows: $#,##0*^.00

Using the above format, the value $1,234.57 appears as follows: $1,234^^^^^^^^^.57

Access generates fill characters so that the displayed text completely fills the display area.

%

Place as the last character in your format string to multiply the value by 100 and include a trailing percent sign.

E or e

Use to generate scientific (exponential) notation and to display a minus sign preceding negative exponents. It must be used with other characters, as in 0.00E-00.

E+ or e+

Use to generate scientific (exponential) notation and to display a minus sign preceding negative exponents and a plus sign preceding positive exponents. It must be used with other characters, as in 0.00E+00.

[color]

Use brackets to display the text in the color specified. Valid color names are Black, Blue, Green, Cyan, Red, Magenta, Yellow, and White. A color name must be used with other characters, as in 0.00[Red].

Inside Out-Don’t Get Fooled by the Format Property 

Keep in mind that what you specify in Format and Decimal Places properties affects only what you see on your screen-these settings do not modify the actual data in the underlying table in any way. For example, if you specify a format that displays two decimal places but the underlying data type contains additional precision (such as a Currency data type that always contains four decimal places), you’ll see a rounded value. If you later sum the values, the total might not agree with the sum of the displayed values. Likewise, if you specify a format that displays only the date portion of a Date/Time data type, you won’t see any time portion unless you click the control. If we had a penny for every time we’ve had to explain this concept in the support newsgroups, we would be very wealthy, indeed!

For example, to display a number with two decimal places and comma separators when positive, enclosed in parentheses and shown in red when negative, Zero when 0, and Not Entered when Null, you would specify the following:

 #, ##0.00; (#, ##0.00)[Red];"Zero";"Not Entered"

To format a U.S. phone number and area code from a numeric field, you would specify the following:

 (000) 000–0000

Specifying a Format for Text

If you don’t specify a Format property setting for a control that displays a text value, Access left aligns the data in the control. You can specify a custom format with one entry or with two entries separated by semicolons. If you include a second format specification, Access uses that specification to show empty values (a zero-length string). If you want to test for Null, you must use the Immediate If (IIf) and IsNull built-in functions. See “Showing the Null Value in Text Fields” on page 657 for details.

By default, Access fills text placeholder characters (@ and & using characters from the underlying data from right to left. If a text field contains more characters than the number of placeholder characters you provide, Access first uses up the placeholder characters and then displays the remaining characters as though you had specified the @ placeholder character in that position. Table 12–3 lists the formatting characters that are applicable to the Text data type.

Table 12–3: Formatting Characters for the Text Data Type
Open table as spreadsheet

Character

Usage

@

Use this placeholder character to display any available character in this position. If all available characters in the underlying text have been placed, any extra @ placeholder characters generate blanks. For example, if the text is abc and the format is @@@@@, the resulting display is left-aligned and has two blank spaces on the left preceding the characters.

&

Use to display any available character in this position. If all available characters in the underlying text have been placed, any extra & placeholder characters display nothing. For example, if the text is abc and the format is &&&&&, the resulting display shows only the three characters left-aligned.

<

Use to display all characters in lowercase. This character must appear at the beginning of the format string and can be preceded only by the ! specification.

>

Use to display all characters in uppercase. This character must appear at the beginning of the format string and can be preceded only by the ! specification.

+ $ () or a blank space

Use these characters anywhere you want in your format string.

“text”

Use double quotation marks to embed any text you want displayed.

\

Use to always display the character immediately following (the same as including a single character in double quotation marks).

!

Use to force placeholders to fill left to right instead of right to left. If you use this specification, it must be the first character in the format string.

*

Use to designate the immediately following character as the fill character. Access usually displays formatted text data left-aligned and filled with blank spaces to the right You can embed the fill character anywhere in your format string. For example, you can specify a format string as follows:

> (@ (@ *! (@ (@ (@ (@ (@

Using the above format, the value abcdef appears as follows:

A!!!!!!!!!!!!!!!BCDEF

(And the above string has a leading blank.)

If you force the pattern to be filled from the left by adding a leading exclamation point, the data appears as follows:

AB!!!!!!!!!!!!!!CDEF

(And the above string has a trailing blank.)

Access generates fill characters so that the displayed text completely fills the display area.

[color]

Use brackets to display the text in the color specified. Valid color names are Black, Blue, Green, Cyan, Red, Magenta, Yellow, and White. A color name must be used with other characters, as in >[Red].

(Keep in mind that in the absence of placeholder characters, Access places the characters as though you had specified (@ in all positions.)

For example, if you want to display a six-character part number with a hyphen between the second character and the third character, filled from the left, specify the following:

 !@@-@@@@

To format a check amount string in the form of Fourteen Dollars and 59 Cents so that Access displays an asterisk (*) to fill any available space between the word and and the cents amount, specify the following:

 **@@@@@@@@

Using this format in a text box wide enough to display 62 characters, Access displays Fourteen Dollars and 59 Cents as

 Fourteen Dollars and *********************************59 Cents

and One Thousand Two Hundred Dollars and 00 Cents as

 One Thousand Two Hundred Dollars and *****************00 Cents

Inside Out-Showing the Null Value in Text Fields 

As you might have noticed, there is no third optional format specification you can supply for a Null value in a text field as there is with Number, Currency, and Date/Time data types. If the field is Null, Access displays it as though it is empty. If the field can contain an empty string or a Null, you can distinguish it visibly by using the second optional format specification. Assuming your text field is five characters long, your Format specification could look like

 @@@@@;"<empty string>"

If the field has a value, Access displays the value. If the field is an empty string, you will see <empty string> in the text box until you click it. If the field is Null, the text box will be blank.

An alternative is to use the IIf and IsNull built-in functions in the Control Source property of the text box. Your control source could look like

 =IIf(IsNul1([FieldToDisplay]), "*Nul1 Value*",[FieldToDisplay])

If you do this, however, you won’t be able to update the field because the source will be an expression.

Specifying a Format for Date/Time

If you don’t specify a Format property setting for a control that displays a date/time value, Access displays the date/time in the General Date format. You can also select one of the six other Format property settings shown in Table 12–4.

Table 12–4: Format Property Settings for the Date/Time Data Type
Open table as spreadsheet

Format

Description

General Date

Displays the date as numbers separated by the date separator character. Displays the time as hours, minutes, and seconds separated by the time separator character and followed by an AM/PM indicator. If the value has no time component, Access displays the date only. If the value has no date component, Access displays the time only. Example: 3/17/2007 06:17:55 PM.

Long Date

Displays the date according to the Long Date setting in the Regional And Language Options section of Windows Control Panel. Example: Saturday, March 17, 2007.

Medium Date

Displays the date as dd-mmm-yyyy. Example: 17-Mar-2007.

Short Date

Displays the date according to the Short Date setting in the Regional And Language Options section of Windows Control Panel. Example: 3/17/2007. To avoid confusion for dates in the twenty-first century, we strongly recommend you take advantage of the Use Four-Digit Year formatting options. Click the Microsoft Office Button, click Access Options, click the Advanced category, and then set these options in the General section.

Long Time

Displays the time according to the Time setting in the Regional And Language Options section of Windows Control Panel. Example: 6:17:12 PM.

Medium Time

Displays the time as hours and minutes separated by the time separator character and followed by an AM/PM indicator. Example: 06:17 PM.

Short Time

Displays the time as hours and minutes separated by the time separator character, using a 24-hour clock. Example: 18:17.

You can also specify a custom format with one entry or with two entries separated by semicolons. If you include a second format specification, Access uses that specification to show Null values. Table 12–5 lists the formatting characters that are applicable to the Date/Time data type.

Table 12–5: Formatting Characters for the Date/Time Data Type
Open table as spreadsheet

Character

Usage

Time separator

Use to show Access where to separate hours, minutes, and seconds. Use the time separator defined in the Regional And Language Options section of Windows Control Panel. In the English (U.S.) layout, the separator is a colon (:).

Date separator

Use to show Access where to separate days, months, and years. Use the date separator defined in the Regional And Language Options section of Windows Control Panel. In the English (U.S.) layout, the separator is a slash (/).

c

Use to display the General Date format.

d

Use to display the day of the month as one or two digits, as needed.

dd

Use to display the day of the month as two digits.

ddd

Use to display the day of the week as a three-letter abbreviation. Example: Saturday = Sat.

dddd

Use to display the day of the week fully spelled out

ddddd

Use to display the Short Date format.

dddddd

Use to display the Long Date format.

w

Use to display a number for the day of the week. Example: Sunday =1.

m

Use to display the month as a one-digit or two-digit number, as needed.

mm

Use to display the month as a two-digit number.

mmm

Use to display the name of the month as a three-letter abbreviation. Example: March = Mar.

mmmm

Use to display the name of the month fully spelled out.

q

Use to display the calendar quarter number (1–4).

y.

Use to display the day of the year (1–366).

yy

Use to display the last two digits of the year.

yyyy

Use to display the full year value (within the range 0100–9999).

h

Use to display the hour as one or two digits, as needed.

hh

Use to display the hour as two digits.

n?

Use to display the minutes as one or two digits, as needed.

nn

Use to display the minutes as two digits.

s.

Use to display the seconds as one or two digits, as needed.

ss

Use to display the seconds as two digits.

ttttt

Use to display the Long Time format.

AM/PM

Use to display 12-hour clock values with trailing AM or PM, as appropriate.

A/P or a/p

Use to display 12-hour clock values with trailing A or P, or a or p, as appropriate.

AMPM

Use to display 12-hour clock values using morning/afternoon indicators as specified in the Regional And Language Options section of Windows Control Panel.

+ $ ( ) or a blank space

Use these characters anywhere you want in your format string.

"text"

Use double quotation marks to embed any text you want displayed.

\

Use to always display the character immediately following (the same as including a single character in double quotation marks).

*

Use to designate the immediately following character as the fill character. Access usually displays formatted date/time data rightaligned and filled with blank spaces to the left. You can embed the fill character anywhere in your format string. For example, you can specify a format string as follows:

mm/yyyy ** hh:nn

Using the above format, the value March 17, 2007 06:17:55 PM appears as follows:

03/2007 ************** 18:17

Access generates fill characters so that the displayed text completely fills the display area.

[color]

Use brackets to display the text in the color specified. Valid color names are Black, Blue, Green, Cyan, Red, Magenta, Yellow, and White. A color name must be used with other characters, as in ddddd[Red].

For example, to display a date as full month name, day, and year (say, May 29, 2007) with a color of cyan, you would specify the following:

 mmmm dd, yyyy[Cyan]

Specifying a Format for Yes/No Fields

You can choose from among three standard formats-Yes/No, True/False, or On/Off-to display Yes/No data type values, as shown in Table 12–6. The Yes/No format is the default. As you saw earlier, it’s often more useful to display Yes/No values using a check box or a button rather than a text box.

Table 12–6: Format Property Settings for the Yes/No Data Type
Open table as spreadsheet

Format

Description

Yes/No (the default)

Displays 0, as No and any nonzero value as Yes.

True/False

Displays 0, as False and any nonzero value as True.

On/Off

Displays 0, as Off and any nonzero value as On.

You can also specify your own custom word or phrase for Yes and No values. Keep in mind that a Yes/No data type is actually a number internally. (1 is Yes, and 0, is No.) So, you can specify a format string containing three parts separated by semicolons just as you can for a number. Leave the first part empty (a Yes/No value is never a positive number) by starting with a semicolon, specify a string enclosed in double quotation marks (and with an optional color modifier) followed by a semicolon in the second part for the negative Yes values, and specify another string (also with an optional color modifier) in the third part for the zero No values.

To display Invoice Sent in red for Yes and Not Invoiced in blue for No, you would specify the following:

 ;"Invoice Sent"[Red] ;"Not Invoiced"[Blue]

image from book
How Format and Input Mask Work Together

If you specify both an Input Mask setting (see Chapter 4) and a Format property setting, Access uses the Input Mask setting to display data when you move the focus to the control and uses the Format setting when the control does not have the focus. If you don’t include a Format setting but do include an Input Mask setting, Access formats the data using the Input Mask setting. Be careful not to define a Format setting that conflicts with the Input Mask. For example, if you define an Input Mask setting for a phone number that looks like

 !\(###") "000\-0000;0;_

(which stores the parentheses and hyphen with the data) and a Format setting that looks like

 (&&&) @@@–@@@@

your data will be displayed as

 (206() 5) 55–1212

image from book

Adding a Scroll Bar

When you have a field that can contain a long data string (for example, the Notes field in the tblReservationRequests table), it’s a good idea to provide a scroll bar in the control to make it easy to scan through all the data. This scroll bar appears whenever you select the control. If you don’t add a scroll bar, you must use the arrow keys to move up and down through the data.

To add a scroll bar, first open the form in Design view. Select the control, and open its property sheet. Then set the Scroll Bars property to Vertical. For example, if you open the frmXmplReservationRequests form in Form view and tab to (or click) the Notes text box, the vertical scroll bar appears, as shown in Figure 12–44.

image from book
Figure 12–44: When you click in the Notes text box, Access displays a scroll bar.

Enabling and Locking Controls

You might not want users of your form to select or update certain controls. You can set these conditions with the control’s Enabled and Locked properties. For example, if you use a control to display an AutoNumber field, you can be certain that Access will provide the field’s value. So, it’s a good idea to set the control’s Enabled property to No (so that the user can’t select it) and the control’s Locked property to Yes (so that the user can’t update it). Table 12–7 shows the effects of the Enabled and Locked property settings. Note, however, that if you want the user to be able to use the Access built-in Find facility to search for a particular AutoNumber value, you should leave Enabled set to Yes to allow the user to select the field and find values in it.

Table 12–7: Settings for the Enabled and Locked Properties
Open table as spreadsheet

Enabled

Locked

Description

Yes

Yes

Control can have the focus. Data is displayed normally and can be copied or searched but not changed.

No

No

Control cannot have the focus. Control and data appear dimmed.

Yes

No

Control can have the focus. Data is displayed normally and can be copied and changed.

No

Yes

Control cannot have the focus. Data is displayed normally but can’t be copied or changed.

In some cases, you might want to allow a control to be selected with the mouse but to be skipped over as the user tabs through the controls on the form. You can set the control’s Tab Stop property to No while leaving its Enabled property set to Yes. This might be useful for controls for which you also set the Locked property to Yes. Setting the Tab Stop property to No keeps the user from tabbing into the control, but the user can still select the control with the mouse to use the Find command or to copy the data in the control to the Clipboard.

Setting the Tab Order

As you design a form, Access sets the tab order for the controls in the order in which you place the controls on the form. When you move a control to a new location, Access doesn’t automatically change the tab order. Also, when you delete a control and replace it with another, Access places the new control at the end of the tab order. If you want to change the tab order that Access created, you can set a different tab order.

You probably should do this with your sample employees form because you moved controls around after you initially placed them on the form. (If you want to test the existing order, try tabbing through the controls in one record in frmXmplEmployee5-you should see the pointer jump from OfficeLocation in the first column to Photo in the second column and then back to Password in the first column.) Open your form in Design view, select the Detail section (or any control in the Detail section), and then click the Tab Order button in the Control Layout group on the Arrange tab to open the Tab Order dialog box, as shown in Figure 12–45.

image from book
Figure 12–45: You can change the tab order on the form by using the Tab Order dialog box.

You can click the Auto Order button to reorder the controls so that the tab order corresponds to the arrangement of the controls on the form, from left to right and from top to bottom-but that’s probably not what you want in this case. Because this form has two columns, you might want to rearrange the tab order to first move down one column and then the other. You can make custom adjustments to the list by clicking the row selector for a control to highlight it and then clicking the row selector again and dragging the control to its new location in the list. As you can see, the Photo and WorkPhone controls don’t appear where they should in the Custom Order list. Click Photo, and drag it down after HomePhone. Click WorkPhone, and drag it up to follow OfficeLocation. Click OK to save your changes to the Custom Order list.

You can also change an individual control’s place in the tab order by setting the control’s Tab Index property. The Tab Index property of the first control on the form is 0, the second is 1, and so on. If you use this method to assign a new Tab Index setting to a control and some other control already has that Tab Index setting, Access resequences the Tab Index settings for controls appearing in the order after the one you changed. The result is the same as if you had dragged the control to that relative position (as indicated by the new Tab Index setting) in the Tab Order dialog box. (We find it easier to use the Tab Order dialog box.)

Adding a Smart Tag

Microsoft introduced smart tags in Microsoft Office XP. Smart tags are little applications that you can hook into your documents to recognize items such as names, addresses, or stock symbols and provide options, or actions, for recognized fields. For example, you might have an address smart tag in an Office Word document that provides an option to open a map to the location. In an Office Excel spreadsheet, you might define a smart tag for a stock symbol column to go look up the latest price on the Web.

If you have Microsoft Visual Studio, you can actually build your own smart tag applications with Visual Basic. You can download the Smart Tag Software Development Kit (SDK) by going to www.microsoft.com/downloads/ and performing a search on the keywords smart tags. Most Word and Excel smart tag applications have two parts: a recognizer and a set of actions. When a smart tag is active in Word or Excel, the recognizer code runs as you type data and decides whether what you typed is something for which the smart tag has an action. If the smart tag recognizes the text, it passes available actions back to the application, and you see a Smart Tag option available that you can click to invoke one of the actions.

Access 2007 supports smart tags but in a slightly different way than Word or Excel. You can define a smart tag for labels, text boxes, combo boxes, and list boxes. For text boxes, combo boxes, and list boxes, the smart tag uses the current value of the control as specified in the Control Source property. For labels, the smart tag uses the contents of the Caption property. Because data in Access not only has a specific data type but also a specific meaning, the recognizer code in a smart tag does not come into play. Access assumes that you know that the data in the label, text box, combo box, or list box is something the smart tag understands. So, you can use smart tags in Access that have only actions defined.

The 2007 Office release installs a few smart tags that you can use in Access 2007:

  • Date   A smart tag that uses a date/time value to schedule a meeting or show your Microsoft Outlook calendar on that date.

  • Telephone Number   A smart tag that accepts a phone number and opens the matching contact from your contacts list.

  • Financial Symbol   A smart tag that can accept a NYSE or NASDAQ stock symbol and display the latest quote, company report, or news from the MSN Money Central Web site.

  • Person Name   A smart tag that can accept a person name (first name and last name) or e-mail address and send an e-mail, schedule a meeting, open the matching contact from your contacts list, or add the name to your contacts list.

Caution 

If you assign a smart tag to a control containing data that the smart tag cannot handle, the smart tag won’t work, and it might generate an error.

In your employees form, the EmailName is a hyperlink field that opens a new message to the e-mail address when you click it. However, you might also want to use the Person Name smart tag to provide additional options. To add this smart tag, open your form in Design view, click the EmailName text box, open the Property Sheet window, click the Data tab, and scroll down to the last property in the list-Smart Tags. Click the property, and then click the Build button to open the Smart Tags dialog box, as shown in Figure 12–46.

image from book
Figure 12–46: You can define smart tags for your controls using the Smart Tags dialog box.

Select the Person Name check box, and click OK to set the property. Note that you can also click the More Smart Tags button to go to the Microsoft Web site to download and install additional smart tags.

After defining a smart tag, switch to Form view. Controls that have a smart tag defined display a small triangle in the lower-right corner. Rest your mouse pointer on the triangle or tab into the control, and you’ll see the smart tag information box appear. Click the down arrow next to the box to see the action choices, as shown in Figure 12–47. Click the action you want to activate that action.

image from book
Figure 12–47: You can select a smart tag action from the menu that appears.

Understanding Other Control Properties

As you’ve already discovered, many of the properties for controls that can be bound to fields from your form’s record source are exactly the same as those you can set in table Design view on the General or Lookup tab. (See Chapter 4, for more details.) If you do not specify a different setting in the control, the form uses the properties you defined for the field in your table. In some cases, a particular field property setting migrates to a different property in the bound control on your form. For example, the Description property of a field becomes the Status Bar Text property of the bound control. The Caption property of a field moves to the Caption property of a bound control’s associated label.

Table 12–8 describes control settings not yet discussed and explains their usage. The table lists the properties in the sequence you will find them on the All tab in the Property Sheet window.

Table 12–8: Other Control Properties
Open table as spreadsheet

Property

Description

Visible

Specify Yes (the default) to make the control visible in Form view. Specify No to hide the control. You will find this property useful when you begin to automate your application and write code to optionally display/hide controls depending on the contents of other fields. See Chapter 20 for details.

Text Format

For controls that can display or be bound to text, you can specify whether the data is stored as plain text or rich text. When you set this property to Rich Text, the data can appear with embedded formatting such as italics or bold.

Datasheet Caption

You can assign a caption for this control that will be displayed when the form is in Datasheet view. The caption appears as a column header.

Show Date Picker

You can specify For Dates (the default) to instruct Access to display a date picker button to the right of the control when the control is bound to a date/time field. Select Never if you do not want Access to display the date picker control.

Width, Height, Top, Left

These properties specify the location and size of the control. Access automatically adjusts these settings when you move a control to a new location or adjust its size. You can enter specific values if you want a control to be placed in a particular location or have a specific size.

Back Style

Choose Normal (the default) to be able to specify a color for the background of the control. Choose Transparent to allow the color of any control or section behind the control to show through.

Back Color, Border Style, Border Width, Border Color, Special Effect, Font Name, Font Size, Font Weight, Font Underline, Font Italic, Fore Color

Access automatically sets these properties when you choose a setting on one of the available buttons in the Font group on the Design contextual tab under Form Tools. You can enter a specific setting in these properties rather than choose an option on the Ribbon. For the color options, you can click the Build button next to the property to select a custom color from the palette of available colors on your computer.

Text Align

The default setting is General, which left aligns text and right aligns numbers. You also can choose Left, Center, and Right options (also available in the Font group on the Design tab) to align the text to the left, in the center, or to the right, respectively. The final option, Distribute, spreads the characters evenly across the available display space in the control.

Line Spacing

You can specify a different line spacing for the text displayed. The default is 0, which spaces the lines based on the font type and size.

Is Hyperlink

Fields that are the Hyperlink data type are always displayed as a hyperlink. You can change this setting to Yes to treat nonHyperlink data type fields as hyperlinks. The default is No.

Display As Hyperlink

Choose If Hyperlink (the default) to instruct Access to display the data as a hyperlink only if the underlying data type is Hyperlink. Choose Always to display the data as a hyperlink even if the data type is not Hyperlink. Choose Screen Only to display the control as a hyperlink only when in Form view.

Gridline Style Top, Gridline Style Bottom, Gridline Style Left, Gridline Style Right

These properties control the style of the gridlines around the control. Transparent (the default) specifies that no gridlines appear. You can choose between Solid, Dashes, Short Dashes, Dots, Sparse Dots, Dash Dot, and Dash Dot Dot. You can also use the Style button in the Gridlines group on the Design tab to set these properties.

Gridline Color

Specify a color to use if you have set gridlines to a value other than Transparent. You can click the Build button next to the property to select a custom color from the palette of available colors on your computer. The default color is black (#000000).

Gridline Width Top, Gridline Width Bottom, Gridline Width Left, Gridline Width Right

These properties control the thickness of the gridlines around controls if you have specified a Control Style setting other than Transparent. You can choose from Hairline, 1 pt (the default), 2 pt, 3 pt, 4 pt, 5 pt, and 6 pt. You can also use the Width button in the Gridlines group on the Design tab to set these properties.

Left Margin, Top Margin, Right Margin, Bottom Margin

In a text box control, you can specify alternative margins for the text displayed. The default for all these properties is 0, which provides no additional margin space. You can also use the Control Margins button in the Control Layout group on the Arrange tab to adjust these settings to four options-None, Narrow, Medium, or Wide.

Top Padding, Bottom Padding, Left Padding, Right Padding

These properties control the amount of space between the control and any gridlines. You can set an amount in inches different from the default of 0.0208 inches.

Horizontal Anchor

This specifies how the control is anchored horizontally when it is in a control layout You can choose Left (the default) to place the control on the left side, Right to place the control on the right side, or Both to stretch the control equally across the control layout You can also use the Anchoring button in the Size group on the Arrange tab to set this property.

Vertical Anchor

This specifies how the control is anchored vertically when it is in a control layout You can choose Top (the default) to place the control at the top, Bottom to place the control at the bottom, or Both to stretch the control equally across the control layout from top to bottom. You can also use the Anchoring button in the Size group on the Arrange tab to set this property.

Can Grow, Can Shrink

These properties apply to controls on a report or in Print Preview. See Chapter 16, “Advanced Report Design,” for details.

Display When

Choose Always (the default) to display this control in Form view, in Print Preview, and when you print the form. Choose Print Only to display the control only when you view the form in Print Preview or you print the form. Choose Screen Only to display the control only when in Form view.

Reading Order

Choose Context (the default) to set the order the characters are displayed based on the first character entered. When the first character is from a character set that is normally read right to left (such as Arabic), the characters appear right to left. Choose Left-To-Right or Right-To-Left to override the reading order.

Scroll Bar Align

Choose System (the default) to align scroll bars based on the form’s Orientation property setting. See the section “Understanding Other Form Properties” on page 676 for details. Choose Right or Left to override the form setting.

Numeral Shapes

On an Arabic or Hindi system, you can choose settings to alter the way numbers are displayed. The default setting is System, which displays numbers based on your system settings.

Keyboard Language

System (the default setting) assumes the keyboard being used is the default for your system. You can also choose from any available installed keyboard.

Filter Lookup

Choose Database Default (the default setting) to honor the options you set in the Advanced category in the Access Options dialog box. Choose Never to disable the lookup of values in Filter By Form. Choose Always to enable the lookup of values in Filter By Form regardless of your Access Options settings.

On Click through On Undo

You can set these properties to run a macro, a function, or an event procedure when the specific event described by the property occurs for this control. See Part 6, “After Completing Your Application,” for details.

Enter Key Behavior

Default (the default setting) specifies that pressing the Enter key in this control performs the action described in the Move After Enter setting in the Advanced category in the Access Options dialog box. The New Line In Field setting specifies that pressing Enter creates a new line in the underlying text. This setting is useful for large text or memo fields, especially when the control is more than one line high and has a vertical scroll bar defined.

ControlTip Text

You can enter a custom message that appears as a control tip when you rest your mouse pointer on the control for a few seconds. You might find this especially useful for command buttons to further describe the action that occurs when the user clicks the button.

Shortcut Menu Bar

You can design a custom shortcut menu for your forms and reports, and you enter the name of your custom menu in this property. This property exists for backward compatibility with Access 2003 and earlier.

Help Context ID

You can create a custom Help file for your application and identify specific topics with a context ID. If you want a particular topic to appear when a user presses F1 when the focus is in this control, enter the ID of the topic in this property. See Chapter 28, “Designing Forms in an Access Project,” for details.

Auto Tab

Choose Yes to cause an automatic tab to the next field when the user enters a number of characters equal to the field length. The default is No.

Vertical

You can design a control that displays text to run vertically down the form (narrow width and tall height). When you do that, you can set Vertical to Yes to turn the text display 90 degrees clockwise. The default is No.

Allow AutoCorrect

Specify Yes (the default) to enable autocorrection as you type text, similar to the AutoCorrect feature in Word. You can customize AutoCorrect options by clicking the AutoCorrect Options button in the Proofing category in the Access Options dialog box. Specify No to turn off this feature.

IME Hold, IME Mode, IME Sentence Mode

These properties determine how Kanji characters are processed on a Japanese language system.

Tag

You can use this property to store additional descriptive information about the control. You can write Visual Basic code to examine and set this property or take a specific action based on the property setting. The user cannot see the contents of the Tag property.

image from book
Be Careful When Setting Control Validation Rules

Two properties that deserve special mention are Validation Rule and Validation Text. As you know, you can specify these properties for most fields in your table. When you build a form that is bound to data from your table, the validation rules in the table always apply. However, you can also specify a validation rule for many bound controls on your form. You might want to do this if, on this particular form, you want a more restrictive rule to apply.

However, you can get in trouble if you specify a rule that conflicts with the rule in the underlying table. For example, in the HousingDataCopy.accdb sample database, you can find a validation rule on the BirthDate field in the tblEmployees table that disallows entering a birth date for someone who is younger than 18 years old. The validation rule is as follows:

 <=(Date()–(365*18))

What do you suppose happens if you subsequently enter a Validation Rule property for the BirthDate text box control on your form that requires the person to be 18 or younger? You can try it by opening your employees form in Design view, clicking the BirthDate text box, and entering the following in the Validation Rule property in the property sheet:

 >(Date()–(365*18))

So that you can determine which validation rule is preventing you from changing the data, set the Validation Text property to something like “Violating the control validation rule.” Now, switch to Form view, and try to type a value that you know violates the table rule, such as 1/1/2007. When you try to tab out of the field, you should see the message from the table: “You cannot enter an employee who is younger than 18 years old.” Now, try to enter a date for an older person, such as 1/1/1969, and press Tab to move out of the control. You should see the validation text that you just entered for the control. The bottom line is you have set up the rules so that no value is valid when you try to edit with this form. (You’ll have to press Esc to clear your edit to be able to close the form.)

image from book




Microsoft Office Access 2007 Inside Out
MicrosoftВ® Office Access(TM) 2007 Inside Out (Microsoft Office Access Inside Out)
ISBN: 0735623252
EAN: 2147483647
Year: 2007
Pages: 234

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net