📄 ch06.htm
字号:
<HR>
</BLOCKQUOTE>
<H2><FONT COLOR="#000077"><B>Controls: List Box Create</B></FONT></H2>
<P>Creating a <I>list box</I> is similar to creating a <I>combo box</I> (See "Controls:
Combo Box Create."), especially for important properties such as Bound Column,
Row Source, and Column Widths. A list box allows you only to choose from an item
in the list and does not allow you to type new values. However, when you click in
a list box, you can type the first letter to move to an existing item.
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT> If you don't have adequate room on a form,
use a combo box instead of a list box.
<HR>
</BLOCKQUOTE>
<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
<OL>
<B>1.</B> From the <I>Design View</I> of a <I>form</I>, click the <I>Toolbox</I>
if necessary and make sure the <I>Control</I> Wizards button is selected.
<P><B>2.</B> Click the List Box button on the toolbar and click in the form where
you want the list box to appear. The List Box Wizard opens.</P>
<P><B>3.</B> To type your values that will appear in the list box, choose I Will
Type the Values I Want, choose <U>N</U>ext, type the number of columns and values
in each column you want. If you type more than one column, choose which column will
be the source for the value for the underlying <I>field</I>, which field you want
to store the value in, and the <I>label</I> for the list box on the next screens.</P>
<P><B>4.</B> To use an existing <I>table</I> or <I>query</I>, on the first screen
of the wizard choose the I Want The List Box To Look Up The Values In A Table Or
Query. Choose the table or query, the fields you want to see in the list, and the
column width of the fields and whether you want to hide the <I>key</I> column. As
in Step 3, also choose the column source underlying field, which field you want store
the value in, and the label for the list box on the next screens.</P>
<P><B>5.</B> If you want to use the list box to move the form to a specific <I>record</I>,
you usually place the box in the form header. On the first step of the List Box Wizard,
choose the Find a Record (third choice), choose the fields you want, the column widths,
and the label for your list box on the next screens.
</OL>
<P>After you finish the wizard, the list box appears on your form. To see or modify
the properties, right-click the list box and choose <U>P</U>roperties.
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>If you use a list box (or combo
box) to locate a record (see preceding Step 5), Access creates a procedure for the
After Update <I>property</I>. See the Event Tab in List Box <I>dialog box</I>.
<HR>
</P>
<P>
<HR>
<FONT COLOR="#000077"><B>TIP:</B></FONT><B> </B>You can convert a list box to a combo
box or <I>text box</I>. Choose F<U>o</U>rmat, C<U>h</U>ange To and <U>C</U>ombo Box
or T<U>e</U>xt Box.
<HR>
</BLOCKQUOTE>
<H2><FONT COLOR="#000077"><B>Controls: Move</B></FONT></H2>
<P>You drag controls to move them to a desired location. However, getting the controls
to line up is easier to accomplish if you use the F<U>o</U>rmat, <U>A</U>lign menu.
(See "Controls: Align.")
<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
<OL>
<B>1.</B> In <I>Design View</I> of a <I>form</I> or <I>report</I>, select one or
more controls.
<P><B>2.</B> Position the mouse pointer hand on the border of one of the controls
and drag to move the selected <I>control</I>(s) and attached labels.</P>
<P><B>3.</B> To move only the control or attached <I>label</I>, position the mouse
pointer finger on the upper left corner of the control (the larger box) and drag.
</OL>
<H2><FONT COLOR="#000077"><B>Controls: Option Button Create</B></FONT></H2>
<P>Generally, it's a good idea to use standard Windows conventions for your forms'
interface. For this reason, a <I>check box</I> means a yes/no option and an <I>option
button</I> means only one option out of a <I>group</I> of options can be selected.
(See "Controls: Check Box Create" and "Controls: Option Group Create.")
However, you can create an option button as a yes/no alternative where a filled circle
means yes and a blank circle means no. Some programs call these radio buttons.
<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
<OL>
<B>1.</B> In <I>Design View</I> of a <I>form</I>, make sure the <I>Toolbox</I> and
<I>Field</I> List are visible.
<P><B>2.</B> Click the Option Button tool on the Toolbox and then drag the name of
the <I>yes/no field</I> from the Field List to the form design area.</P>
<P><B>3.</B> If you want to add another option button to an option group, click the
Option Button tool and move into the option group (it will become selected) and click.
If necessary, change the Option Value on the Properties Sheet Data tab and the <I>caption</I>
(Properties Sheet Format tab) of the <I>label</I> attached to the option.
</OL>
<H2><FONT COLOR="#000077"><B>Controls: Option Group Create</B></FONT></H2>
<P>An <I>option group</I> enables you to click one of a series of possible answers.
The option group itself contains the reference to the field in its <I>Control</I>
Source <I>property</I>. Each <I>option button</I> within the group refers to a potential
value for the option group field. The values for the option buttons must be numeric
(with no decimals) so the option group feature can only be used for numeric fields
that can accept Byte, <I>Integer</I>, or Long Integer field sizes. (See also "Field:
Size" in the Table and Database Design part of this book.)</P>
<P>Because screen space constrains you to about four options in a group, a <I>combo
box</I> can be a better alternative if you have more options. (See "Controls:
Combo Box Create.")
<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
<OL>
<B>1.</B> In Form Design View, click the Option Group button on the toolbar and click
in the form where you want the option group to appear. The Option Group Wizard opens.
<P><B>2.</B> On the first steps of the wizard, type the <I>label</I> names for each
option within the group. Also, choose if you want one of the options to be the default
choice for new records and the values that each option represents.</P>
<P><B>3.</B> On the next step, choose which field stores the value of the option.
The other choice, Save the Value for Later Use, could be used in programming. Choose
<U>N</U>ext.</P>
<P><B>4.</B> Decide whether you want option buttons, <I>toggle buttons</I>, or <I>check
boxes</I> within your option group and what style the group will have; then, choose
<U>N</U>ext.</P>
<P><B>5.</B> On the final screen of the wizard, give the option group a <I>caption</I>.
Type the name and choose <U>F</U>inish.
</OL>
<P>To add option buttons, toggle buttons, or check boxes into the option group after
it is created, click one of those buttons in the <I>Toolbox</I> and drag into the
option group until it is highlighted. Edit the caption of the label and change the
Option Value property of the new option.
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>If you are using the option group
for programming rather than to fill in a field, you would add <I>code</I> to the
After Update property (on Event tab). A common way to handle options would be to
use the <TT>Select Case</TT>, <TT>End Case</TT> statements. Between these two statements,
use Case <I>number</I> on one line followed by programming statements on the next
lines. <I>Number</I> would be the value for each option within the group.
<HR>
</BLOCKQUOTE>
<H2><FONT COLOR="#000077"><B>Controls: Properties Change</B></FONT></H2>
<P><I>Controls</I> are edited in the Design View for forms and reports. Some aspects
of a control can be altered, for example, through manipulating the control's shape
on the design surface or resizing the control. Most aspects of controls are edited
in the <I>Property</I> sheet for that control.</P>
<P>To view a control's Property sheet, select the control and click the Properties
button on the toolbar.</P>
<P>You can click either the All, Format, Data, <I>Event</I>, or Other page to see
a subset of the properties for that control.
<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
<OL>
<B>1.</B> In <I>Design View</I> of a <I>form</I> or <I>report</I>, click a control
or section, and click the <I>Properties</I> button on the toolbar to open the Properties
sheet.
<P><B>2.</B> Click the Property you want to set; or navigate to it using the Up or
Down arrow keys, or the Page Up or Page Down keys.</P>
<P><B>3.</B> Enter or edit the value of the property.</P>
<P><B>4.</B> If the property has a down arrow displayed, you can select the value
from the drop-down list; or if the property displays a build button (...), you can
click that button and alter the <I>expression</I> in the Expression <I>Builder</I>.</P>
<P><B>5.</B> Press the Enter <I>key</I> or click outside of the row to establish
your changes.
</OL>
<P>For more help on the expression builder, see "Expression: Using the Builder"
in the Calculations part of this book.
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>TIP:</B></FONT><B> </B>If you need to open up a larger window
for that property, press the Shift+F2 key to open a Zoom box. To get help for a particular
property, press the F1 key while that property is current.
<HR>
</BLOCKQUOTE>
<H2><FONT COLOR="#000077"><B>Controls: Select</B></FONT></H2>
<P>Before you move, delete, change font attributes, align, or change properties of
a <I>control</I>, you need to select the control first. Depending on your needs,
there are numerous ways to select controls.</P>
<P>When you select a control, small, black sizing handles appear around the border
of the control. When the mouse pointer is on a sizing handle, the pointer turns to
a double-headed arrow, enabling you to size the control. (See also "Controls:
Size.") The upper left corner of a selected control displays a larger box that
enables you to move the control independent of the attached <I>label.</I> (See also
"Controls: Move.") In each of the following steps, you are in Design View
of a form or report.
<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
<OL>
<B>1.</B> To select one control, click it. If you want to select the control by its
name, choose it from the list on the <I>Select Objects</I> button on the Formatting
(Form/Report) toolbar.
<P><B>2.</B> To select multiple adjacent controls, drag the mouse to draw an outline
around the controls (do not start dragging on top of a control). All the controls
within the outline and any control that touches the outline are selected. This is
sometimes referred to as lassoing controls.</P>
<P><B>3.</B> To select multiple controls, click the mouse on the first control, hold
down Shift, and click the other controls.</P>
<P><B>4.</B> To select all controls in a vertical or horizontal column or row, move
the mouse pointer into the horizontal or vertical ruler and click or drag in the
ruler.
</OL>
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>CAUTION:</B></FONT> When trying to select controls, you
might accidentally move or size one or more controls. Immediately click the Undo
Current Field/Record button to return the controls to the previous position.
<HR>
</BLOCKQUOTE>
<P>To unselect controls, click in the design background, not on a control.
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>You can change the effect of lassoing
controls. Choose <U>T</U>ools, <U>O</U>ptions, Forms/Reports tab. In the Selection
Behavior section, choose <U>P</U>artially Enclosed to lasso as mentioned in the preceding
Step 2 or F<U>u</U>lly Enclosed to require that the entire control be within the
outline to be selected.
<HR>
</BLOCKQUOTE>
<H2><FONT COLOR="#000077"><B>Controls: Size</B></FONT></H2>
<P>For some controls, especially labels with larger fonts, you will need to resize
the <I>control</I>. This is also true for most other controls with underlying <I>field</I>
values. When you use a Form or <I>Report</I> wizard (see also "Forms: Create
with Form Wizard" and "Reports: Create with Report Wizard") or AutoForm
or AutoReport (see also "Forms: Create with AutoForm" and "Reports:
Create with AutoReport") to create a form or report, <I>text box</I> controls
are generally wide enough to display the widest value. When you drag fields from
the Field List to add them in Design View, the control might not be wide enough to
display the field's text.
<H3><FONT COLOR="#000077"><B>Steps</
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -