Download The Unofficial Guide to Microsoft Office Access 2007 (Unofficial Guide) PDF

TitleThe Unofficial Guide to Microsoft Office Access 2007 (Unofficial Guide)
Author
LanguageEnglish
File Size6.8 MB
Total Pages676
Document Text Contents
Page 2

Unofficial
Guide®

the

to

Access™
2007

Jim Keogh

Microsoft® Office

01_045978 ffirs.qxp 2/28/07 11:08 PM Page i

Page 338

303CHAPTER 13 ■ USING CONTROLS ON A FORM

Copying and deleting a control
Here’s another time-saver when creating unbound controls. Sometimes
you’ll find yourself creating multiple versions of the same control such as
the Text Box control used for a person’s name and address. You must
create and format each version of the control.

A better approach is to create and format one control and then copy
and paste the control on the form as many times as you need.

1. Click the control and press Ctrl+C to copy the control from the
form to the Clipboard.

2. Press Ctrl+V to paste the control from the Clipboard to the form.

Don’t fret if you make an error. Simply click a control and press
Delete to remove it from the form.

A Label control is sometimes displayed automatically with an input
control such as a Text Box control. Make sure both controls are selected
if you want to delete both of them.

Naming controls
When I bring up the topic of naming a control, I usually get strange
looks from some of my colleagues who are not familiar with creating
macros (see Chapter 18) or interacting with forms using Visual Basic.
Each control already has a name. That is, Text Box control is the name of
the Text Box control. That’s true, but each instance of a control has a
unique name too.

Think of a control in the Controls group on the Design tab as a tem-
plate that describes the control. It isn’t actually a control. When you click
the control onto the form, Access 2007 uses the template to create an
instance of the control.

Hack
Copying a control is a way to make sure similar controls have a uniform appear-
ance and size. Create one control, and then resize it and change its properties as
necessary so it has the characteristics you want to see. Copy the control, and the
copy has the same size and property setting as the original control.

20_045978 ch13.qxp 2/28/07 11:08 PM Page 303

Page 339

304 PART IV ■ USING FORMS

So the Text Box control in the Controls group describes a Text Box to
Access 2007. It’s like a blueprint for creating a Text Box control. When
you click the Text Box control on the form, Access 2007 uses this blue-
print to create a real Text Box control, sometimes referred to as an
instance of the Text Box control.

Each instance is given a unique name by Access 2007. The first Text
Box you create is called Text1 and the next Text2. The names aren’t very
creative nor does it indicate the nature of the control, but it is the easiest
names that Access 2007 can generate.

You should give each instance of a control a more informative name,
a name that implies the content of the control, if the control is used in a
macro or Visual Basic program.

A macro and Visual Basic program have instructions that tell Access
2007 to do something, which might be to read or write a value to a con-
trol or read or set a property of a control. The instruction might say,
“Read the value of Text1 and write the value to Text2.”

Access 2007 has no problem identifying Text1 and Text2 as long as
there are controls with those names. However, anyone reading the
instructions will have to examine the form to know how these Text Box
controls are used in the form.

A better approach is to give each an informative name. Naming con-
ventions specify two parts to a name — the prefix and the name. The
prefix is a three letter abbreviation that describes the type of control (see
Table 13.1) and the name describes the contest of the control.

For example, txtCustomerFirstName is the name of the instance of
the Text Box control that contains the first name of a customer. You’d
write txtCustomerFirstName when referring to this control in a macro or
Visual Basic program.

To enter a name, do the following:

1. Click the control.

2. Click Property Sheet in the Tools group on the Design tab. This dis-
plays the control’s properties.

3. Click the All tab. This displays all the properties for the control.

4. Enter the name in the Name property (see Figure 13.4).

20_045978 ch13.qxp 2/28/07 11:08 PM Page 304

Page 675

Straight from the experts—authoritative, must-know information
on today’s hottest technologies. Each Unofficial Guide presents

unbiased information based on the author’s real-world experience,
giving you more than the official line.

Get it straight.

For a complete list of Unofficial Guides on technology, travel,
real estate, business, health, and lifestyle topics, go to wiley.com.

Available wherever books are sold.

44_045978 bob.qxp 2/28/07 11:08 PM Page 640

Similer Documents