Documente Academic
Documente Profesional
Documente Cultură
Data form
Worksheet with form and ActiveX controls
Form controls
ActiveX controls
Drawing tools objects
Working with controls and objects on a worksheet
Determining the type of control on a worksheet
VBA UserForms
Excel can automatically generate a built-in data form for your range or table. The
data form displays all column headers as labels in a single dialog box. Each label
has an adjacent blank text box in which you can enter data for each column, up
to a maximum of 32 columns. In a data form, you can enter new rows, find rows
by navigating, or (based on cell contents) update rows and delete rows. If a cell
contains a formula, the formula result is displayed in the data form, but you
cannot change the formula by using the data form.
Top of Page
1.3.2 Worksheet with Form and ActiveX controls
For added flexibility, you can add controls and other drawing objects to the
drawing canvas of a worksheet, and combine and coordinate them with
worksheet cells. For example, you can use a list box control to make it easier for
a user to select from a list of items. Or, you can use a spin button control to make
it easier for a user to enter a number.
Because controls and objects are stored on the drawing canvas, you can display
or view controls and objects alongside associated text that is independent of row
and column boundaries without changing the layout of a grid or table of data on
your worksheet. Most of the time, many of these controls can also be linked to
cells on the worksheet and do not require VBA code to make them work. You can
set properties that determine whether a control floats freely or moves and resizes
together with a cell. For example, you might have a check box that you want to
move together with its underlying cell when the range is sorted. However, if you
have a list box that you want to keep in a specific location at all times, you
probably do not want it to move together with its underlying cell.
Excel has two types of controls: Form controls and ActiveX Controls. In addition to
these sets of controls, you can also add objects from the Drawing tools, such as
AutoShapes, WordArt, SmartArt graphic, or text boxes.
The following sections describe these controls and drawing objects, and also
explain how to work with these controls and objects in more detail.
Top of Page
1.3.2.1 Form controls
Form controls are the original controls that are compatible with earlier versions of
Excel, starting with Excel version 5.0. Form controls are also designed for use on
XLM macro sheets.
You use Form controls when you want to easily reference and interact with cell
data without using VBA code, and when you want to add controls to chart sheets.
For example, after you add a list box control to a worksheet and link it to a cell,
you can return a numeric value for the current position of the selected item in the
control. You can then use that numeric value in conjunction with
the INDEX function to select different items from the list.
You can also run macros by using Form controls. You can attach an existing macro
to a control, or write or record a new macro. When a user of the form clicks the
control, the control runs the macro.
However, these controls cannot be added to UserForms, used to control events,
or modified to run scripts on web pages.
1.3.2.1.1 Summary of form controls
Butto Exampl Description
n e
Name
Top of Page
1.3.2.2 ActiveX controls
ActiveX controls can be used on worksheet forms, with or without the use of VBA
code, and on VBA UserForms. In general, use ActiveX controls when you need
more flexible design requirements than those provided by Form controls. ActiveX
controls have extensive properties that you can use to customize their
appearance, behavior, fonts, and other characteristics.
You can also control different events that occur when an ActiveX control is
interacted with. For example, you can perform different actions, depending on
which choice a user selects from a list box control, or you can query a database
to refill a combo box with items when a user clicks a button. You can also write
macros that respond to events associated with ActiveX controls. When a user of
the form interacts with the control, your VBA code then runs to process any
events that occur for that control.
Your computer also contains many ActiveX controls that were installed by Excel
and other programs, such as Calendar Control 12.0 and Windows Media Player.
Not all ActiveX controls can be used directly on worksheets; some can be used
only on Visual Basic for Applications (VBA) UserForms. If you try to add any one of
these particular ActiveX controls to a worksheet, Excel displays the message
"Cannot insert object."
However, ActiveX controls cannot be added to chart sheets from the user
interface or to XLM macro sheets. You also can't assign a macro to run directly
from an ActiveX control the same way you can from a Form control.
1.3.2.2.1 Summary of ActiveX controls
Butto Example Description
n
Name
Controlling the display of gridlines while you work with the controls, and
deciding whether to display the gridlines to the user on the final worksheet
form.
Selecting and deselecting controls so that you can specify properties or
make additional adjustments.
Editing text in a control, such as the caption or label.
Grouping, copying, moving, and aligning controls to organize the layout of
the worksheet form.
Resizing and formatting controls to obtain the appearance that you want.
Positioning or sizing a control with a cell.
Protecting controls and linked cells according to your specific data
protection needs.
Enabling or disabling the printing of controls when the worksheet form is
printed.
Deleting unused controls.
You can design a worksheet form with or without cell gridlines in the background.
For example, you might want to turn off cell gridlines and then format all the cells
with the same color or pattern, or even use a picture as a sheet background. To
hide or show the gridlines, on the View tab, in the Show group, clear or select
the Gridlines check box.
Top of Page
1.3.2.5 Determining the type of control that is on your worksheet
Because there are three different types of controls and objects that you can
modify uniquely, you might not know for sure which type of control it is just by
looking at it. To determine the type of control (Form or ActiveX), select and right-
click the control, and then display the shortcut menu:
If the shortcut menu contains the command Edit Text, the object is a
Drawing object.
Top of Page
1.3.3 VBA UserForms
For maximum flexibility, create a UserForm, which is a custom dialog box that
usually includes one or more ActiveX controls. You make UserForms available
from VBA code that you create in the Visual Basic Editor. The high-level steps for
creating a UserForm are as follows:
1. Insert a UserForm into your workbook's VBAProject. You access a
workbook's VBAProject by first displaying the Visual Basic Editor (press
ALT+F11) and then, on the Insert menu in the Visual Basic Editor,
clicking UserForm.
2. Write a procedure to display the UserForm.
3. Add ActiveX controls.
4. Modify properties for the ActiveX controls.
5. Write event-handler procedures for the ActiveX controls.
By using UserForms, you can also utilize advanced form functionality. For
example, you can programmatically add a separate option button for each letter
of the alphabet or you can add a check box for each item in a large list of dates
and numbers.
Before creating a UserForm, consider using built-in dialog boxes available from
Excel that might fit your needs. These built-in dialog boxes include the
VBA InputBox and MsgBoxfunctions, the
Excel InputBox method, GetOpenFilename method, GetSaveAsFilenamemethod,
and the Dialogs object of the Application object, which contains all the built-in
Excel dialog boxes.
For more information, explore the Microsoft Office Excel Developer Center.
2 Select or deselect controls on a worksheet
Applies To: Excel 2016 , Excel 2013 , Excel 2010 , Excel 2007
You can group, copy, resize, or format controls on a worksheet form.
NOTES:
You cannot combine Form controls or ActiveX controls with Drawing Tools or
SmartArt Tools objects (such as Shapes and SmartArt graphics) in the same group
selection.
Make sure the Developer tab is visible on the ribbon. For more information, see Show the
Developer tab. Then make sure the Design mode is enabled. To do this,
When youre done working with controls, you need to turn off Design mode.
The control border for an ActiveX control appears as a series of sizing handles:
Top of Page
1. On the Home tab, in the Editing group, click Find & Select.
a. To select objects that are hidden, stacked, or behind text, click Select
Objects, and then draw a box over the objects.
b. To open a task pane where you can select, multiselect, show, hide, or change
the order of objects, click Selection Pane, and then click the options that
you want.
TIP: To select controls using a mouse, press and hold the CTRL key until the controls are
selected.
Top of Page
2. Click the control that you want to select inside the group.
Top of Page
2. Press and hold the CTRL key until the controls are selected.
Top of Page
2. Press TAB to cycle forward or SHIFT+TAB to cycle backward through the controls.
Top of Page
On the Home tab, in the Editing group, click Find & Select, and then do one
of the following:
a. Click Select Objects, and then use the mouse pointer to draw a rectangle
around the objects that you want to select.
b. Click Selection Pane, and then use the pane to select one or more objects.
Top of Page
a. To cancel the selection of one or more controls, click anywhere outside the
control, set of selected controls, or group border.
You use a list box or a combo box, which are similar but slightly different controls, to let
users make multiple choices of items or to enter their own value in a list. Typical examples of
items in these types of lists are employee names, exchange rates, and product items.
Top of Page
a. Click the Microsoft Office Button , and then click Excel Options.
b. In the Popular category, under Top options for working with Excel, select
the Show Developer tab in the Ribboncheck box, and then click OK.
The Ribbon is a component of the Microsoft Office Fluent user interface.
2. On the Developer tab, in the Controls group, click Insert, and then under Form
Controls, click List box .
3. Click the worksheet location where you want the upper-left corner of the list box to appear.
You can also right-click the control, and then click Format Control.
a. In the Input range box, enter a cell reference to a range that contains the values to
display in the list box.
b. In the Cell link box, enter a cell reference that contains the list box selection.
The linked cell returns the number of the selected item in the list box. The first item in the range
returns a value of 1, the second item in the range returns a value of 2, and so on.
Use this number in a formula to return the actual item from the input range.
For example, a dessert preference form has a list box that is linked to cell C1, the input range for the
list is D1:D5, and the items in the range are: "Ice Cream" (D1), "Cake" (D2), "Liqueur" (D3), "Candy"
(D4), and "Chocolate" (D5). The following formula, entered in cell B1, returns the value "Liqueur"
from range D1:D5 if the value of C1 is 3, based on the current selection in the list box.
=INDEX(D1:D5,C1)
1. Under Selection type, specify how items can be selected in the list box by doing one of the
following:
If you set the selection type to Multi or Extend, the cell that is specified in the Cell link box
returns a value of 0 and is ignored. The Multi and Extend selection types require the use of
Microsoft Visual Basic for Applications (VBA) code. In these cases, consider using the ActiveX list
box control.
Top of Page
a. Click the Microsoft Office Button , and then click Excel Options.
b. In the Popular category, under Top options for working with Excel, select
the Show Developer tab in the Ribboncheck box, and then click OK.
2. On the Developer tab, in the Controls group, click Insert, and then under ActiveX
Controls, click List Box .
3. Click the worksheet location where you want the upper-left corner of the list box to appear.
4. To edit the ActiveX control, make sure that you are in design mode. On the Developer tab,
in the Controls group, turn onDesign Mode .
5. To specify the control properties, on the Developer tab, in the Controls group,
click Properties .
You can also right-click the control, and then click Properties.
The Properties dialog box appears. For detailed information about each property, select the
property, and then press F1 to display a Visual Basic Help topic. You can also type the property name
in the Visual Basic Help Search box. The following section summarizes the properties that are
available.
General:
If you want to specify Use this property
Whether the control is loaded when the workbook is opened. (Ignored for ActiveX AutoLoad (Excel)
controls.)
Whether the control can receive the focus and respond to user-generated events. Enabled (Form)
The way the control is attached to the cells below it (free floating, move but do not size, Placement (Excel)
or move and size).
Text:
Font attributes (bold, italic, size, strikethrough, underline, and weight). Bold, Italic, Size, StrikeTh
m)
The default run time mode of the Input Method Editor (IME). IMEMode (Form)
Whether the size of the control adjusts to display full or partial lines of text. IntegralHeight (Form)
How text is aligned in the control (left, center, or right). TextAlign (Form)
The distance between the control and the left or top edge of the worksheet. Left, Top (Form)
Formatting:
The visual appearance of the border (flat, raised, sunken, etched, or bump). SpecialEffect (Form)
The type of pointer that is displayed when the user positions the mouse over a particular MousePointer (Form)
object (for example, standard, arrow, or I-beam).
If you want to specify Use this property
The list style (plain, with option buttons, or with check boxes). ListStyle (Form)
How the control searches its list while the user types (first letter, complete entry, or MatchEntry (Form)
none)
The column to store in the Text property when the user selects a row. TextColumn (Form)
The item that appears in the topmost position in the list. TopIndex (Form)
To create a list box that displays one value in the list box but saves another value in the linked
cell, create a two-column list box, and then hide one of the columns by setting
its ColumnWidths value to 0. For example, you can set up a two-column list box that
contains the names of holidays in one column and dates associated with the holidays in a
second column. To present the holiday names to users, specify the first column as
the TextColumn. To store the dates of the holidays, specify the second column as
the BoundColumn. To hide the dates of the holidays, set the ColumnWidths property of
the second column to 0.
Top of Page
a. Click the Microsoft Office Button , and then click Excel Options.
b. In the Popular category, under Top options for working with Excel, select
the Show Developer tab in the Ribboncheck box, and then click OK.
2. On the Developer tab, in the Controls group, click Insert, and then under Form
Controls, click Combo box .
3. Click the worksheet location where you want the upper-left corner of the combo box to
appear.
4. To display the text box, drag the left-center sizing handle to the right.
You can also right-click the control, and then click Format Control.
a. In the Input range box, enter a cell reference to a range that contains the values to
display in the drop-down list of the combo box.
b. In the Cell link box, enter a cell reference that contains the selection in the drop-
down list of the combo box.
The linked cell returns the number of the selected item in the drop-down list of the combo box. The
first item in the range returns a value of 1, the second item in the range returns a value of 2, and so on.
Use this number in a formula to return the actual item from the input range. For example, a dessert
preference form has a combo box linked to cell C1, the input range for the list is D1:D5, and the items
in the range are: "Ice Cream" (D1), "Cake" (D2), "Liqueur" (D3), "Candy" (D4), and "Chocolate"
(D5). The following formula, entered in cell B1, returns the value "Liqueur" from range D1:D5 if the
value of C1 is 3, based on the current selection in the combo box.
=INDEX(D1:D5,C1)
If you want to create a combo box that enables the user to edit the text in the text box, consider using
the ActiveX Combo Boxcontrol.
1. In the Drop-down lines box, enter the number of lines to display in the drop-down list of
the combo box. If the value is:
o Less than the number of items in the range specified in the Input range box, a
scroll bar is displayed.
o Equal to or greater than the number of items in the range specified in the Input
range box, no scroll bar is displayed.
Top of Page
a. Click the Microsoft Office Button , and then click Excel Options.
b. In the Popular category, under Top options for working with Excel, select
the Show Developer tab in the Ribboncheck box, and then click OK.
2. On the Developer tab, in the Controls group, click Insert, and then under ActiveX
Controls, click Combo Box .
3. Click the worksheet location where you want the upper-left corner of the combo box to
appear.
4. To edit the ActiveX control, make sure that you are in design mode. On the Developer tab,
in the Controls group, turn onDesign Mode .
5. To specify the control properties, on the Developer tab, in the Controls group,
click Properties .
You can also right-click the control, and then click Properties.
The Properties dialog box appears. For detailed information about each property, select the
property, and then press F1 to display a Visual Basic Help topic. You can also type the property name
in the Visual Basic Help Search box. The following section summarizes the properties that are
available.
General:
Whether the control is loaded when the workbook is opened. (Ignored for ActiveX AutoLoad (Excel)
controls.)
Whether the control can receive the focus and respond to user-generated events. Enabled (Form)
The way the control is attached to the cells below it (free floating, move but do not size, Placement (Excel)
or move and size).
Text:
Whether a word or a character is the basic unit used to extend a selection. AutoWordSelect (Form)
Font attributes (bold, italic, size, strikethrough, underline, and weight). Bold, Italic, Size, StrikeTh
m)
Whether selected text remains highlighted when the control does not have the focus. HideSelection (Form)
The default run time mode of the Input Method Editor (IME). IMEMode (Form)
Whether the user can select a line of text by clicking to the left of the text. SelectionMargin (Form)
How text is aligned in the control (left, center, or right). TextAlign (Form)
Whether the size of the control automatically adjusts to display all the contents. AutoSize (Form)
The distance between the control and the left or top edge of the worksheet. Left, Top (Form)
Formatting:
The visual appearance of the border (flat, raised, sunken, etched, or bump). SpecialEffect (Form)
Whether an automatic tab action occurs after a user has entered the maximum number AutoTab (Form)
of characters for the control.
The selection behavior when entering the control (select all or do not change). EnterFieldBehavior (Form
The type of pointer that is displayed when the user positions the mouse over a particular MousePointer (Form)
If you want to specify Use this property
The symbol that is displayed on the drop button (down arrow, plain, ellipsis, or DropButtonStyle (Form)
underscore).
The list style (plain, with option buttons, or with check boxes). ListStyle (Form)
How the control searches its list while the user types (first letter, complete entry, or MatchEntry (Form)
none)
Whether a value entered as text must match an entry in the existing list. MatchRequired (Form)
When to show the drop button (never, with focus, or always). ShowDropButtonWhen (Fo
How the user chooses or sets the value (drop-down combo or drop-down list). Style (Form)
If you want to specify Use this property
The column to store in the Text property when the user selects a row. TextColumn (Form)
The item that appears in the topmost position in the list. TopIndex (Form)
To create a combo box that displays one value in the combo box but saves another in the
linked cell, create a two-column combo box, and then hide one of the columns by setting
its ColumnWidths value to 0. For example, you can set up a two-column combo box that
contains the names of holidays in one column and associated dates for the holidays in a second
column. To present the holiday names to users, specify the first column as the TextColumn.
To store the dates of the holidays, specify the second column as the BoundColumn. To hide
the dates of the holidays, set the ColumnWidthsproperty of the second column to 0.
To create a combo box that does not enable the user to enter new values, set Style to 2. To
create a combo box that enables a user to enter new values that are not found in the list,
set Style to 1, which is the default. In this case, you must write VBA code if you want to
dynamically update the list values.
Top of Page
This article does not explain how to enter data manually or enter data simultaneously on multiple
worksheets. For information about how to manually enter data, see the article Enter data
manually in worksheet cells.
4.1 What do you want to do?
Automatically repeat values that already exist in the column
After Excel completes what you started typing, do one of the following:
NOTE:
Excel completes an entry only when the cursor is at the end of the current cell contents.
Excel bases the list of potential AutoComplete entries on the column that contains the active
cell. Entries that are repeated within a row are not automatically completed.
3. Click Advanced, and then under Editing options, clear or select the Enable
AutoComplete for cell values check box to turn automatic completion of cell values on
or off.
Top of Page
3. Click Advanced, and then under Editing options, clear or select the Enable fill
handle and cell drag-and-drop check box to hide or show the fill handle.
4. To avoid replacing existing data when you drag the fill handle, make sure that the Alert
before overwriting cells check box is selected. If you don't want to see a message about
overwriting nonblank cells, you can clear this check box.
4.3.2 Use Auto Fill Options to change how the selection is filled
After you drag the fill handle, the Auto Fill Options button appears so that you can change how
the selection is filled. For example, you can choose to fill just cell formats by clicking Fill
Formatting Only, or you can choose to fill just the contents of a cell by clicking Fill Without
Formatting.
3. Click Advanced, and then under Cut, copy, and paste, clear the Show Paste Options
button when content is pastedcheck box.
Top of Page
4.4.1 Fill the active cell with the contents of an adjacent cell
1. Select an empty cell that is below, to the right, above, or to the left of the cell that contains the
data that you want to use to fill the empty cell.
2. On the Home tab, in the Editing group, click Fill, and then click Down, Right, Up,
or Left.
TIP: To quickly fill a cell with the contents of an adjacent cell, you can press CTRL+D to fill
from the cell above or CTRL+R to fill from the cell to the left. To fill a cell with the contents
of a cell below it (that is, to fill up), on the Home tab, in the Editing group, click Fill, and
then click Up. To fill a cell with the contents of a cell to the right (fill left), on the Home tab,
in the Editing group, click Fill, and then click Left.
4.4.2 Drag the fill handle to fill data into adjacent cells
1. Select the cells that contain the data that you want to fill into adjacent cells.
2. Drag the fill handle across the cells that you want to fill.
3. To change how you want to fill the selection, click Auto Fill Options , and then click
the option that you want.
NOTE: If you drag the fill handle up or to the left of a selection and stop in the selected cells
without going past the first column or the top row in the selection, Excel deletes the data
within the selection. You must drag the fill handle out of the selected area before releasing the
mouse button.
Top of Page
2. Drag the fill handle across the cells that you want to fill.
3. To choose how you want to fill the selection, click Auto Fill Options , and then click
the option that you want.
NOTE: If automatic workbook calculation is not enabled, formulas will not recalculate when
you fill cells. To check your workbook calculation options, do the following:
5. Under Excel, click Options, and then click the Formulas category.
o Automatic except for data tables Formulas recalculate, unless the formula is in a
data table.
4.5.1 Tips
You can also fill the active cell with the formula of an adjacent cell by using the Fill command
(on the Home tab in theEditing group), or by pressing CTRL+D to fill a cell below or
CTRL+R to fill a cell to the right of the cell containing the formula.
You can automatically fill a formula downward, for all adjacent cells that it applies to, by
double-clicking the fill handle of the first cell that contains the formula. For example, cells
A1:A15 and B1:B15 contain numbers, and you type the formula=A1+B1 in cell C1. To copy
that formula into cells C2:C15, select cell C1 and double-click the fill handle.
Top of Page
1. Select the first cell in the range that you want to fill.
For example, if you want the series 1, 2, 3, 4, 5..., type 1 and 2 in the first two cells. If you want the
series 2, 4, 6, 8..., type 2and 4. If you want the series 2, 2, 2, 2..., you can leave the second cell blank.
When you fill a series, the selections are extended as shown in the following table. In this table, items
that are separated by commas are contained in individual adjacent cells on the worksheet.
1, 2, 3 4, 5, 6,...
2. Drag the fill handle across the range that you want to fill.
To fill in increasing order, drag down or to the right. To fill in decreasing order, drag up or to the left.
4.6.1 Tips
You can also specify the type of series by using the right mouse button to drag the fill handle
over the range and then clicking the appropriate command on the shortcut menu. For example,
if the starting value is the date JAN-2007, click Fill Months for the series FEB-2007, MAR-
2007, and so on; or click Fill Years for the series JAN-2007, JAN-2008, and so on.
If the selection contains numbers, you can control the type of series that you want to create.
Top of Page
4.7 Fill cells with a series of numbers
1. On the Home tab, in the Editing group, click Fill, and then click Series.
o Linear Creates a series that is calculated by adding the value in the Step
value box to each cell value in turn.
o Growth Creates a series that is calculated by multiplying the value in the Step
value box by each cell value in turn.
o Date Creates a series that fills date values incrementally by the value in the Step
value box and is dependent on the unit specified under Date unit.
o AutoFill Creates a series that produces the same results as dragging the fill handle.
3. You can suppress series AutoFill by holding down CTRL as you drag the fill handle of a
selection of two or more cells. The selected values are then copied to the adjacent cells, and
Excel does not extend a series.
NOTE: A custom list can only contain text or text mixed with numbers. For a custom list that
contains numbers only, such as 0 through 100, you must first create a list of numbers that is
formatted as text.
2. On the Home tab, in the Number group, click the arrow on the Number Format box,
and then click Text.
TIP: You might have to click More Number Formats to see the Text format in the list.
4. Click Advanced, and then under General, click Edit Custom Lists.
5. Verify that the cell reference of the list of items that you selected is displayed in the Import
list from cells box, and then click Import.
The items in the list that you selected are added to the Custom lists box.
6. Click OK twice.
7. On the worksheet, click a cell, and then type the item in the custom fill series that you want to
use to start the list.
8. Drag the fill handle across the cells that you want to fill.
3. Click Advanced, and then under General, click Edit Custom Lists.
4. In the Custom lists box, click NEW LIST, and then type the entries in the List
entries box, starting with the first entry.
6. When the list is complete, click Add, and then click OK twice.
7. On the worksheet, click a cell, and then type the item in the custom fill series that you want to
use to start the list.
8. Drag the fill handle across the cells that you want to fill.
3. Click Advanced category, and then under General, click Edit Custom Lists.
4. In the Custom lists box, select the list that you want to edit or delete, and then do one of the
following:
o To edit the fill series, make the changes that you want in the List entries box, and
then click Add.
Top of Page
5 ControlSource Property
Applies To: Access 2007
5.1 Applies to
You can use the ControlSource property to specify what data appears in a control. You can display
and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an
expression. Read/write String.
expressio n.ControlSource
expression Required. An expression that returns one of the objects in the Applies To list.
5.2 Setting
The ControlSource property uses the following settings.
Setting Description
A field The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in
name inside the control change the corresponding data in the field. (To make the control read-only, set the L
click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in th
An The control displays data generated by an expression. This data can be changed by the user but isn't save
expression
You can set the ControlSource property for a control by using the control's property sheet, a macro,
or Visual Basic for Applications (VBA) code.
You can also set the ControlSource property for a text box by typing a field name or expression
directly in the text box in form Design view or report Design view.
For a report, you can set this property by selecting a field or typing an expression in the
Field/Expression pop-up window in the Group, Sort and Total pane.
5.3 Remarks
For a report group level, the ControlSource property determines the field or expression to group on.
NOTE: The ControlSource property doesn't apply to check box, option button, or toggle
button controls in an option group. It applies only to the option group itself.
For reports, the ControlSource property applies only to report group levels.
Forms and reports act as "windows" into your database. You specify the primary source of data for a
form or report by setting its RecordSource property to a table, query, or SQL statement. You can then
set the ControlSource property to a field in the source of data or to an expression. If
the ControlSource property setting is an expression, the value displayed is read-only and not saved
in the database. For example, you can use the following settings.
Sam ple setting Description
LastName For a control, data from the LastName field is displayed in the control. For
Office Access 2007 groups the data on last name.
=Date( ) + 7 For a control, this expression displays a date seven days from today in the co
=DatePart("q",ShippedDate) For a control, this expression displays the quarter of the shipped date. Fo
groups the data on the quarter of the shipped date.
5.4 Example
The following example sets the ControlSource property for a text box named AddressPart to a field
named City:
Forms!Customers!AddressPart.ControlSource = "City"
The next example sets the ControlSource property for a text box named Expected to the
expression =Date() + 7.
1. In the Navigation Pane, select a table or query that contains the records you want on your
report.
Access creates a simple tabular report and then displays it in Layout View. If there are many
fields in the report, it will probably extend across more than one page. Before applying any
grouping or sorting, you might want to resize columns (and delete unwanted columns) so that
the report fits on one page width. To delete a column, right-click it and then click Delete
Column.
3. Right click a column on which you want to group or sort, and then click Group On [field
name] or click one of the Sortoptions. For example, to group on the Priority column, right-
click the Priority column and then click Group On Priority.
When applying grouping, Access moves the grouping field to the leftmost column, and groups
the remaining columns based on that column. In some cases, Access also adds a grand total to
the Report Footer section.
4. Optionally, view and fine-tune your grouping and sorting options by following the procedures
in the section, Add or modify grouping and sorting in an existing report.
2. Click the Tables/Queries drop-down list and choose the table or query that contains the
fields you want on your report.
Access moves them to the Selected Fields list. Alternatively, you can click the buttons located
between the Available Fields box and the Selected Fields box to add or remove the selected
field or to add all or remove all of the fields.
4. If there are fields in another table or query that you also want to put on your report, click
the Tables/Queries drop-down list again and choose the other table or query, and continue
to add fields.
1. On the page of the Report Wizard that asks Do you want to add any grouping
levels?, click one of the field names in the list, and then click Next.
2. To add grouping levels, double-click any of the field names in the list to add them to your
report.
You can also remove a grouping level by double-clicking it in the page display on the right side of the
dialog box. Use the arrow buttons to add and remove grouping levels, and adjust the priority of a
grouping level by selecting it and clicking the up or down priority buttons. Access adds each grouping
level and shows it nested within its parent grouping level.
The grouping interval lets you customize how records are grouped. In the previous illustration, records
are grouped on the ShippedDate field, which is a Date/Time data type. The Report Wizard offers
choices appropriate to the field type in the Grouping intervals list. Thus, because ShippedDate is a
Date/Time type, you can choose to group by actual value
(Normal), Year, Quarter, Month, Week, Day, Hour and Minute. If the field were a Text data
type, you could choose to group by the entire field (Normal), or perhaps by the first one to five
characters. For a numeric data type, you can choose to group by value ( Normal), or by range in
selected increments.
1. Click the first drop-down list and choose a field on which to sort.
You can click the button to the right of the list to toggle between ascending and descending order
(Ascending is the default). Optionally, click the second, third, and fourth drop-down lists to choose
additional sort fields.
2. Click Summary Options if you want to summarize any of the numeric fields.
Note that the Summary Options button will only be visible if you have one or more numeric fields
in the Detail section your report. The wizard displays the available numeric fields.
3. Select the check box under your choice of Sum, Avg, Min or Max to include those
calculations in the group footer.
You can also choose to show the details and summary or the summary only. In the latter case, totals for
each ShippedDate value are shown (if you selected the check box for Sum, for example), but the
order detail is omitted. You can also choose to show percent of total calculations for sums.
4. Click OK.
5. Follow the directions on the remaining pages of the Report Wizard. On the last page, you can
edit the title of the report. This title will be displayed on the first page of the report, and
Access will also save the report, using the title as the document name. You can edit both the
title and the document name later.
6. Click Finish. Access automatically saves the report and displays it in Print Preview, which
shows you the report as it will look when printed.
You can use the navigation buttons at the bottom of the preview pane to view the pages of the report
sequentially or jump to any page in the report. Click one of the navigation buttons or type the page
number that you want to see in the page number box, and then press ENTER.
In Print Preview, you can zoom in to see details or zoom out to see how well data is positioned on the
page. With the mouse pointer positioned over the report, click once. To reverse the effect of the zoom,
click again. You can also use the zoom control in the status bar.
NOTE: Although the instructions in this section don't use the Group, Sort, and Total pane
directly, it is a good idea to open the pane and observe how it changes as you work. You will
get a better idea of what Access is doing and, as you get more comfortable working with
the Group, Sort, and Total pane, you can use it to make additional adjustments to your
report. To display the Group, Sort, and Total pane:
On the Design tab, in the Grouping & Totals group, click Group & Sort.
On the shortcut menu, click the sort option you want. For example, to sort a text field in
ascending order, click Sort A to Z. To sort a numeric field in descending order, click Sort
Largest to Smallest.
Access sorts the report as you specified. If the Group, Sort, and Total pane is open, you can see
that a new Sort by line for the field has been added.
NOTE: When you apply sorting by right-clicking a field in Layout view, you can only sort one
field at a time. Applying sorting to another field removes the sorting on the first field. This
differs from the sorting behavior in forms, where multiple sort orders can be established by
right-clicking each field in turn and the choosing the sort order you want. To create multiple
sorting levels, see the section Add grouping, sorting, and totals by using the Group, Sort,
and Total pane.
Access adds the grouping level and creates a group header for it. If the Group, Sort, and
Total pane is open, you can see that a new Group on line for the field is added.
Click Total.
Click the operation you would like to perform: Sum, Average, Count Records (to count
all records), Count Values (to count only the records with a value in this
field), Max, Min, Standard Deviation, or Variance.
Access adds a calculated text box control to the report footer, which creates a grand total. Also, if your
report has any grouping levels, Access adds group footers (if not already present) and places the total
in each footer.
NOTE: You can also add totals by clicking the field that you want totaled and then, on
the Design tab, in the Grouping & Totals group, clickTotals.
5.9.2 Add grouping, sorting, and totals by using the Group, Sort, and Total pane
Working in the Group, Sort, and Total pane gives you the most flexibility when you want to add
or modify groups, sort orders, or totals options on a report. Again, Layout view is the preferred view in
which to work because it is much easier to see how your changes affect the display of the data.
On the Design tab, in the Grouping & Totals group, click Group & Sort.
To add a new sorting or grouping level, click Add a group or Add a sort.
A new line is added to the Group, Sort, and Total pane, and a list of available fields is displayed.
You can click one of these field names or you can click expression below the list of fields to enter
an expression. Once you choose a field or enter an expression, Access adds the grouping level to the
report. In Layout view, the display changes immediately to show the grouping or sort order.
For more information about creating expressions, see the article Create an expression.
NOTES:
If there are already several sorting or grouping levels defined, you may need to scroll down in
the Group, Sort, and Totalpane before you can see the Add a group and Add a
sort buttons.
To display all the options for a grouping or sorting level, click More on the level that you
want to change.
Sort order You can change the sort order by clicking the sort order drop-down list, then clicking the
option you want.
Group interval This setting determines how the records are grouped together. For example, you can
group on the first character of a text field so that all that start with "A" are grouped together, all that
start with "B" are grouped together, and so on. For a date field, you can group by day, week, month,
quarter, or you can enter a custom interval.
Totals To add totals, click this option. You can add totals on multiple fields, and you can do multiple
types of totals on the same field.
Click the Total On drop-down arrow and select the field you want to have summarized.
Click the Type drop-down arrow and select the type of calculation to perform.
Select Show Grand Total to add a grand total to the end of the report (in the report footer).
Select Show group totals as % of Grand Total to add a control to the group footer that
calculates the percentage of the grand total for each group.
Select Show in group header or Show in group footer to display the total in the
desired location.
Once all the options have been chosen for a field, you can repeat the process and summarize another
field by selecting the other field from the Total On drop-down list. Otherwise, click outside
the Totals pop-up window to close it.
Title This allows you to change the title of the field being summarized. This is used for the column
heading and for labeling summary fields in headers and footers.
Type the new title in the dialog box, and then click OK.
With/without a header section Use this setting to add or remove the header section that precedes
each group. When adding a header section, Access moves the grouping field to the header for you.
When you remove a header section that contains controls other than the grouping field, Access asks
for confirmation to delete the controls.
With/without a footer section Use this setting to add or remove the footer section that follows each
group. When you remove a footer section that contains controls, Access asks for confirmation to delete
the controls.
Keep group together This setting determines how groups are laid out on the page when the report is
printed. You may want to keep groups together as much as possible to reduce the amount of page
turning that is needed to see the entire group. However, this usually increases the amount of paper
needed to print the report, because most pages will have some blank space at the bottom.
Do not keep group together on one page Use this option if you are not concerned about
groups being broken up by page breaks. For example, a group of 30 items may have 10 items
on the bottom of one page and the remaining 20 items at the top of the next page.
Keep whole group together on one page This option helps minimize the number of page
breaks in a group. If a group cannot fit in the remaining space on a page, Access leaves that
space blank and begins the group on the next page instead. Large groups may still span
multiple pages, but this option minimizes the number of page breaks within the group as much
as possible.
Keep header and first record together on one page For groups with group headers, this
ensures that the group header will not print by itself at the bottom of a page. If Access
determines that there is not enough room for at least one row of data to be printed after the
header, the group begins on the following page.
NOTES:
You cannot combine Form controls or ActiveX controls with Drawing Tools or SmartArt
Tools objects (such as Shapes and SmartArt graphics) in the same group selection.
Make sure the Developer tab is visible on the ribbon. For more information, see Show the
Developer tab. Then make sure the Design mode is enabled. To do this,
click Developer > Design Mode (in Controls group).
When youre done working with controls, you need to turn off Design mode.
The control border for a Form control appears as a dotted pattern and a series of sizing handles:
The control border for an ActiveX control appears as a series of sizing handles:
Top of Page
1. On the Home tab, in the Editing group, click Find & Select.
a. To select objects that are hidden, stacked, or behind text, click Select Objects, and
then draw a box over the objects.
b. To open a task pane where you can select, multiselect, show, hide, or change the order
of objects, click Selection Pane, and then click the options that you want.
TIP: To select controls using a mouse, press and hold the CTRL key until the controls are
selected.
Top of Page
2. Click the control that you want to select inside the group.
Top of Page
6.5 Select multiple controls in a group
1. Click the selection border of the group.
2. Press and hold the CTRL key until the controls are selected.
Top of Page
Top of Page
2. Press TAB to cycle forward or SHIFT+TAB to cycle backward through the controls.
Top of Page
6.8 Select controls and objects that are
on the drawing layer
On the Home tab, in the Editing group, click Find & Select, and then do one of the
following:
a. Click Select Objects, and then use the mouse pointer to draw a rectangle around
the objects that you want to select.
b. Click Selection Pane, and then use the pane to select one or more objects.
Top of Page
a. To cancel the selection of one or more controls, click anywhere outside the control, set
of selected controls, or group border.
b. To cancel the selection of one control at a time in a set of selected controls, hold down
CTRL and click the control.
Top of Page
NOTE: If the Developer tab isn't visible, click File > Options > Customize Ribbon. In
the Main Tabs list, check the Developer box, and then click OK.
4. Click the cell where you want to create the list box.
NOTE: If you want more items displayed in the list box, you can change the font size of
text in the list.
TIP: The cell you choose will have a number associated with the item selected in your
list box, and you can use that number in a formula to return the actual item from the
input range.
NOTE: If you want to use Multi or Extend, consider using an ActiveX list box control.
NOTE: You can also create the list on another worksheet in the same workbook.
NOTE: If the Developer tab isn't visible, click File > Options > Customize Ribbon. In
the Main Tabs list, check the Developer box, and then click OK.
Or
o Under ActiveX Controls, click Combo Box (ActiveX Control).
4. Click the cell where you want to add the combo box and drag to
draw it.
TIPS: To resize the box, point to one of the resize handles, and drag the edge of the
control until it reaches the height or width you want.
o Cell link: The combo box can be linked to a cell where the item
number is displayed when you select an item from the list. Type the cell
number where you want the item number displayed.
For example, cell C1 displays 3 when the item Sorbet is selected, because
it's the third item in our list.
TIP: You can use the INDEX function to show an item name instead of a number. In our
example, the combo box is linked to cell B1 and the cell range for the list is A1:A2. If
the following formula, is typed into cell C1: =INDEX(A1:A5,B1), when we select the
item "Sorbet" is displayed in C1.
o Drop-down lines: The number of lines you want displayed
when the down arrow is clicked. For example, if your list has 10 items and
you don't want to scroll you can change the default number to 10. If you
type a number that's less than the number of items in your list, a scroll bar
is displayed.
3. Click OK.
2. Right-click the combo box and pick Properties, click Alphabetic, and
change any property setting that you want.
Here's how to set properties for the combo box in this picture:
To set this property Do this
Fill color Click BackColor > the down arrow > Pallet, and
then pick a color.
Font type, style or size Click Font > the... button and pick font type, size,
or style.
To set this property Do this
Font color Click ForeColor > the down arrow > Pallet, and then
pick a color.
Link Combo Box to a list Click the box next to ListFillRange and type the cell
range for the list.
Change the number of list Click the ListRows box and type the number of
items displayed items to be displayed.
4. After you complete the formatting, you can right-click the column
that has the list and pickHide.
www.onlinepclearning.com/edit-and-delete-from-a-...
1.
2.
This information can be applied to any Listbox userform that is populated ... we canedit and
delete information in a database from a Excel VBA userform. ... Make sure that you do
not use the click event for this action, it should be double-click.