Access Database Management Guide
Access Database Management Guide
[Link]@[Link]
SUPPORT
ACCESS
SUMMARY
1. The launch
2
ACCESS: DATABASE MANAGEMENT SYSTEM
DATA.
ACCESS is a software in the category of 'relational database management system.'
which offers numerous graphical interfaces for building tables, queries, and
screen forms or printed reports.
A database management system is software that ensures the functions of storage, updating
up to date, research and presentation of this data.
The Microsoft Office Access Getting Started page appears when Access is first started or
lorsque vous fermez une base de données sans fermer Access.
3
2. The creation and modification of a table
An ACCESS database contains one or more relational tables, in which
data is stored.
To create a table:
Creation of fields
Creating the structure of a table involves defining the fields of this table. The names of the fields
it must start with a letter, not exceed 64 characters, it is advised to avoid all
special characters.
It is possible to use uppercase or lowercase letters, but Access does not distinguish between them:
NomAssuré, nomassuré or NOMassuré are equivalent.
It is also necessary to determine the types of data and to configure the properties of
each field using the table creation mode.
When assigning field names, be careful not to use reserved words in Access.
this could get you into trouble later on. It's a case of 'name' and 'date' for example.
Also avoid giving names that are made up of multiple words, or that contain a space.
Access accepts them but this is not the case for all software and you could get into trouble.
during an export for example.
The types of data are declared in the highlighted part of the screenshot below.
4
Define properties of the fields
Creating the structure of a table involves defining the fields of that table.
It is then necessary to determine the types of data and to set the properties of each.
champ using the table creation mode.
The properties and their settings differ from one data type to another, as we
Let's move to the Fields Properties page.
5
and their size.
Numeric type is assigned to all data that takes a numerical value on which it is
possible to perform calculations.
The dates are part of the integer of a number representing a date indicating the number of days.
elapsed since a date that depends on the Windows settings. The decimal part corresponds to the hour.
length in
Type of
possible values name
data
of bytes
yes/no -1 et 0 ; oui/non ; vrai/faux ; actif/inactif 1 octet
octet 0 to 255 1 octet
whole -32768 to +32767 2 octets
9 9
long integer -2 times 10 at +2x10 4 octets
simple real decimal number in floating point with 7 significant figures 4 octets
real double decimal number in floating point with 14 significant digits 8 octets
-922337203685.0000
Monetary 8 octets
477.5808 to +922 337 203 685 477.5807
Date dates range from 1/1/100 to 21/12/9999 8 octets
Auto Number auto-incrementing long integer 8 octets
28 28
-7.9x10 +7.9x10 without decimal or 28 significant digits to the right
decimal 14 bytes
of the decimal separator
A hyperlink allows you to specify a link to a web page by entering the url alone or UnTexte#url#.
Attachment allows specifying an attached file of type Word, Excel, or otherwise
6
Properties of fields
The properties of fields will not be examined exhaustively here, but we will...
we will focus on those that are essential for optimization:
the congestion of the base
data security
the speed of query execution
Likewise, we will not see all the possible values for each property, but
only the most commonly used.
List of field properties
Field size
Format
Input mask
Legend
Default value
Valid if
Error message
Null prohibited
Empty chain allowed
Indexed
Unicode compression allows encoding each character in a text area with a single character.
instead of two as long as it is about Latin characters. The default value is yes.
The properties 'IME mode' and 'IME composition mode' are useful for working in the
Eastern languages, we will not discuss them here.
Active tags are useful for saving time by performing actions in Access that
should normally be executed in other programs. We will not address them for
the moment.
List areas and drop-down lists
7
Field size
It is advisable to define the size of this field more precisely to avoid reserving too much space.
needlessly this significantly slows down research. For example, reserving 50 characters for a
Phone number takes up 5 times too much space.
Format
The format governs the display mode of the data; it does not affect the content itself.
Type text
Numeric type
symbol meaning
. or , decimal separator (indicated in the Windows regional settings)
space or . thousand separator (indicated in Windows regional settings)
# display the numbers if they are significant and display nothing if they are not
0 display the entered numbers or 0 when they are not significant
# ##0"text" displays the text literally after the number
Examples:
Format input Display
# ##0.00 ["1957.5589","125.2","1","957.56","125.20"]
8
Type date
The symbols used to present a date are d m y (for day, month, year) and h m (for hours)
minutes). The current separator is '/' for the date, '-' is also possible and ':' for the time.
1/1/2008 31/12/2008
Format
02:05 12:30
j 1 31
jj 01 31
jjj sea sea
jjjj Tuesday Wednesday
m 1 12
mm 01 12
mmm jan dec
mmmm January December
aa 08 08
aaaa 2008 2008
h 2 12
hh 02 12
n 5 30
nn 05 30
Examples:
Format Display
Friday, October 10
JJJJ J MMMM AAAA
2008
HH hours and NN 10 hours and 25
minutes minutes
JJ-MMM-YYYY 10-oct-2008
HH:NN 09:30
Input mask
The input mask allows determining the nature of the characters that will be accepted, it performs
sort of a first level of control over the information entered.
It consists of three parts separated by ';' all of which are optional, if the first one does not exist.
but the others are irrelevant.
The mask properly said (made up of the symbols below)
0 if Access needs to store delimiters, 1 otherwise
Character to replace (to be used when expecting a specific number of characters)
Character Description
0 Digit (0 to 9, input required, plus (+) and minus (-) signs not accepted)
9 Number or space (optional entry, plus and minus signs not accepted)
# Number or space (optional input, plus and minus signs accepted)
L Letter (A to Z, required entry)
? Letter (A to Z, optional entry)
A Letter or number (mandatory entry)
9
a Letter or number (optional input)
& Any character or space (mandatory entry)
C Any character or space (optional input)
.,:;-/ Separators (the character to use depends on the regional settings of Windows)
< convert all characters to lowercase
> CONVERTIT TOUS LES CARACTÈRES EN MAJUSCULES
! Allows filling the input mask from the right
In case of an entry not matching the mask, a beep sounds for an inappropriate entry.
(letter when a number is required) to validate the area, if characters are missing
mandatory an error message appears
Legend
If the legend does not exist, the field name will be used in the reports and forms to refer to the
concerned data. If it is believed that the field name is not sufficiently clear for the operator
In data entry, it can be replaced by a clearer label by filling in the legend property.
Default value
Allows specifying a default value. If a value is common for a field, it can be set to
default value in order to save time in input.
Valid if
This property allows you to specify a validity condition for the input. For example, you can impose
that a date of birth be between 1/1/1880 and the current date of entry.
Error message
The specified message is displayed in cases where the condition specified in the valid if is not met.
Prévoyez un message qui aide l'utilisateur à saisir les champs convenablement. Éviter par exemple un
Input error
between 5000 and 10000
Null prohibited
The default parameter is 'no'. If 'yes' is entered, it will be impossible to leave the field blank.
of information.
10
Empty string allowed
By default, the parameter is set to 'yes'. We get an empty string, '' by validating the field without entering anything.
in the area. If we set the parameter to "no", we will be required to enter something in the area.
Indexed
Apart from primary keys which are special indexes, two types of indexes can be distinguished: with or
sans doublons. Les index sont utilisés pour optimiser les recherches sur un champ. Le nom d'un contact
It will be an indexed field with duplicates (2 people in the file can be called Dupont). The number
INSEE will be a unique index, the same number cannot be assigned to two people.
different.
Remarks:
ACCESS automatically creates an index when a field has a name suggesting a
identifier (number_xxx, code_xxx ...). Therefore, if necessary, adapt or
remove this index;
To facilitate the updating of composite key tables with multiple fields, it is
strongly recommended to assign them an automatic number as a key
primary. The fields that make up the 'natural' key of the table may constitute
one or more secondary indexes with or without duplicates, as the case may be.
The 'Choice List Assistant' type allows, when entering data in the field, to
choose the field value from a list displaying values from another table.
The links (pointers) existing between tables are called 'relationships' in ACCESS.
These relationships between tables can be represented graphically and are defined through the
operations that follow:
From the workspace, click on the iconor choose the menu options
"Tools" then "Relationships";
link the related fields in each table by a 'held click' starting from the
field that is a primary key or unique index, leading to the duplication of this
champ. The starting table (source table) is the "Table/query" and the destination table
the "Linked table/query" according to ACCESS terminology (in the example, starting from the
"client code" in "CLIENT" and go to the "client code" in "INVOICE";
A 'Relationships' dialog box appears, which allows you to specify the constraints.
to apply. Click on 'Apply Referential Integrity' and 'Create'. ACCESS
indicate by the "linked" side (multiple invoices can be linked to a client) and by 1
the "source" side (the unique origin of the client code) of the integrity constraint
referential.
11
Note:
A referential integrity constraint is a rule that requires that any value entered in
le champ lié soit présente dans le champ source. ACCESS fait automatiquement cette
verification during data input, as soon as the referential integrity constraint is
defined.
"Cascade delete" triggers the automatic deletion of related records when one is deleted.
remove the source.
Remark:
in the 'Relations' screen, the fields that constitute or participate in a key
primary appears in bold characters;
the ACCESS notation on the links is the INVERSE of the cardinalities of the SCD
(1 --> and N ---> 1);
A relationship cannot be established between an ACCESS field of type 'AutoNumber'
and a corresponding digital field in another table only if the latter is
defined as a "Long Integer". Generally, the related fields
must have compatible definitions.
Example:
Displaying all the relationships presents a complete graphical image on the screen of the
structure of relational tables.
A particular relationship can be selected by 'simple click' on the line that represents it,
then deleted by the 'Delete' key. A 'double click' on this line allows you to access the
framework for defining the relationship and modifying it.
12
The input and processing of data from a table
The datasheet view is reserved for data entry in tables. One can create...
additional fields in datasheet mode but I do not recommend it. It is better to
define the data types and the properties of the fields with precision.
by selective search, by clicking on the selection field and then on the icon .
Then follow the instructions in the "Search in the field: ..." window, enter the value
sought and then chosen and close the search window. ACCESS positions itself
on the corresponding record if it exists.
13
Create the relationships between the tables as well as the integrity constraints
referentials;
3. Create a test set (data intended to test the database) or collect the data
real
4. Enter the data while respecting the order imposed by the constraints (a value
must be entered in the 'source' field before being in the 'linked' field).
Note: it is essential not to enter data (6°) in the tables before having defined
all constraints applying to the data, including integrity constraints
references. This will avoid inconsistencies that may later require deletion of
certain relationships, certain data, or even certain tables to be corrected.
14
II. GRAPHIC REQUESTS ACCESS
Whether you create simple Select queries using an Assistant or from Design mode, the
the steps are essentially the same. Just choose the recording source to use, as well as
the fields to include in the request. You can also specify criteria to refine the
results.
Once the Select query is created, execute it to check that it works correctly. For this,
open it in Creation mode. You can then reuse it at any time, as a source
of registering a form, a statement, or another request, for example.
Access offers several types of queries to allow you to execute different operations.
For example, the Select query displays data, the Action query modifies the data in its source.
of data, or create a table. The Parameterized query asks you to enter criteria when you
you execute it.
1. Allows you to change the display mode and switch from creation mode to sheet mode.
data (among others);
2. Allows changing the type of the request being created;
3. Allows executing the query (I will return to the difference between this tool and tool (1)
corresponding to the display in data sheet;
4. Allows adding a table to the current query;
Allows adding the line "Grouping" to generate statistical calculations in the
request;
6. Display the properties window of the selected query or field;
7. Open the expression generator window to facilitate the creation of calculated expressions.
By clicking on the dropdown part of buttons (1) and (2), Access opens submenus revealing
other tools.
In the 'Display' sub-menu, we find in order:
1. Display the creation mode, that is to say the structure of the request;
2. Display the result of the selection query in the form of a data sheet (like in Excel);
(Note that this button will display the relevant records if it is an Action request)
(Update, Delete, Add)
3. Display the SQL syntax generated by Access (very useful for retrieval and implementation
in the VBA code) ;
4. Display a Pivot Table related to the data retrieved by the query;
5. Display a Cross Chart related to the data retrieved by the query.
16
Table panel: contains all the source tables of the query;
2. Tables "source": contain the available fields (Note the primary key displayed in
grass);
3. The join: it is the relationship that exists between the two tables.
4. The structure of the query: groups all the fields necessary for extraction.
desired information;
5. The criteria zone: part of the screen where we can combine the different
selection values.
A query criterion is like a condition that you apply to a field. The criterion defines a
condition, based on field values, expressing what you want to add to the query, by
Example "show only the records where the City field is Paris". (See the Client table)
Add two more criteria to obtain more meaningful results. For example, you do not want
obtain only the records that contain the address and the contact's phone number.
2. In the Criteria line of the Address field, type Is Not Null AND <>"". Do the same for
the Phone field in the lineCriteria.
Note: The criterion Is Not Null AND <>"" is true when a known, non-empty value exists for
the field with a criterion. It is false when there is no known value (Null), or when the value is
empty (""). You can use this expression to check a field for a known value and not
to see.
What to do if you do not want to combine conditions using the AND operator? In other words,
how to specify two or more criteria by including only the records that meet one of them
the two conditions?
17
3. Specify other criteria sets using the operator
OR
Suppose you want to display all records where the City is Paris and containing in
less one contact information (the address or phone number, for example). You want
combine the criteria using the OR operator, as follows:
To specify substitution criteria, complete the Criteria and Or lines in the creation grid.
All records that meet the criteria defined in the Criteria line or Or are part of the
results.
You will now modify the query by entering substitute criteria in the Criteria lines.
and you.
Note: To specify two or more sets of substitution criteria, fill in the lines below.
from the line. Each line represents an independent set of criteria.
In this exercise, you will modify the query 'Contacts in Paris' so that the date of birth and
the age of each individual should be displayed.
Age is the name you use for the calculated field. If you do not enter a name, Access uses a
generic name, for example EXPR1. The string that follows the colon (:) is the expression
who provides the values of each record. The functionDiffDate calculates the difference between two
dates and returns the result in the specified format. The format displays the result in years and the elements.
[DateOfBirth] and Date() of the expression indicate the two date values. The DateFunction sends the
Today's date and [DateNaissance] refers to the DateNaissance field of the underlying table.
Note: The calculation used for Age in this example is an approximation that may be
slightly inaccurate, according to the current month.
Switch to Data Sheet mode. The result includes two additional fields: DateOfBirth and
Age.
5. Synthesize the values of the request
It is easier to summarize the columns of a query in Office Access 2007 than in previous versions.
previous ones from Access. You can add, count, or calculate other aggregate values, and then them
display on a special line (called 'Totals line') which appears under the line marked with a
asterisk (*) in Datasheet mode.
You can use a different aggregate function for each column or choose not to.
synthesize a column.
In this exercise, you will modify the request 'Contacts in Paris' so that the Total line is
displayed.
In the dropdown list, select None or Number. As the Contact Name column displays
textual values, functions such as Sum and Average are of no use, and by
consequently, are not available.
5. In the Age field, select Average. Since the Age field returns a number, the
Sum Functions, Average, Count, Maximum, Minimum, Standard deviation and Variance are
available.
To clear the total of a column, click on the Total row under the relevant column and
selectNone from the dropdown list. To hide theTotal row, under theHome tab, in the
data type group and formatting, click on Totals.
Note: Using the Total line does not modify the underlying SQL instruction.
To set up a query, you need to enter (in brackets) a free wording in the area of
criteria of the considered field (for example = [Enter the item code]).
This label will be displayed by ACCESS when executing the query, to indicate what
value must be entered.
19
Department
RéfClient Society Address City CodePostal PaysOuRégion Winter. Coordinates DateNaissance
Or Region
Baldwin Museum 7, place 03 80 Stéphane
1 Beaune Golden Coast 21203 France 03.12.45
of Science Beaubernard 203 130 Rogert
(201)
Blue Yonder 52 Avenue des Patrice Dupont-
2 Valenciennes North 59300 France 555- 21.03.59
Airways anemones Roc
0123
05 49 Gilles
3 Coho Winery 31 Sun Street Poitiers Vienna 86201 France 01.04.73
413 201 Fabrouque
Contoso 1 Dead-end of 01 85 04
4 Paris 75003 France Fabrice Grand 16.06.67
Pharmaceuticals valleys 12 35
01 15 56
5 Fourth Coffee Paris 75201 France Julien Dupré 09.08.71
10 63
Consolidated 23 rue de la Ille-et- 02 23 62 Christine
6 Rennes 35031 France 27.05.48
Messenger post Nasty 10 10 Huguette
Graphic Design 151 street of the 04 93 39
7 Cannes 6400 France Denise Barré 12.08.61
Institute beach 11 71
3 Avenue de la 05 56
8 Litware, Inc. Bordeaux Gironde 33080 France John Loved 01.09.75
victory 201 201
Francis
9 Tailspin Toys 22 Church Street Paris 74301 France 15.02.53
Parrèche
01 15 56
10 Woodgrove Bank 37 Main Street Paris 75056 France Martin Gorbot September 25, 1938
10 63
III. ACCESS FORMS
The ACCESS form
A form is a database object that allows you to enter, modify, or display data.
from a table or a query. Forms also allow for controlling access to the data by
only displaying certain fields or rows of data. For example, it is possible that
some users may need to display only certain fields of a table made up of a multitude
of fields. By providing them with a form that contains only these fields, it will be easier for them
to use the database. You can also add buttons and other features to a
Form to automate frequently performed operations.
1. In the navigation pane, click on the table or query that contains the data you
wish to include in the form.
2. Under the Create tab, in the Forms group, click on Form.
Access creates the form and displays it in Page mode. This mode allows you to make changes to
the design of the form while having the displayed data. For example, you can adjust the
Size of text areas according to the data to be displayed, if necessary.
If Access determines that only one table has a one-to-many relationship with the table or the query that has
used to create the form, Access adds a datasheet to the form, based on the table
ou la requête associée. Par exemple, si vous créez un formulaire standard à partir de la table Employés, et
that a one-to-many relationship is defined between the Employees table and the Orders table, the sheet of
data displays all the records from the Orders table related to the record
Active employee. You can delete the data sheet from the form if you feel you do not need it.
need. If there are several tables linked by a one-to-many relationship with the table that was used to create the
form, Access does not add data sheets to the form.
Create a form using the Form Assistant
To be more selective about the fields to include on your form, you can use
the Form Assistant instead of the various form creation tools mentioned earlier.
You can also define how the data is grouped and sorted, and you can
use fields from multiple tables or queries, provided that you have previously specified them
relations between tables and queries.
1. Under the Create tab, in the Forms group, click on More Forms, then on
Assistant Form .
Note: If you want to include fields from multiple tables or queries in your form,
do not click on Next or on Finish after selecting the fields of the first table or
request on the first page of the Form Assistant. Instead, repeat the steps to
select a table or a query, then click on the additional fields you want
include in the form. Then click on Next or Finish to continue.
Note: Several tools from the Controls group are only accessible when your form is
open in Creation mode. To switch to Creation mode, right-click on the name of the
form in the navigation pane, then click on Design Mode .
You can use Assistants to create command buttons, list boxes, sub-
forms, drop-down list areas and option groups. Under the Create tab, in the group
Checks, if the option Use Assistants control is not enabled, click on it to enable.
If you prefer to create controls without the help of the Assistant, click on the option Use Assistants
1. Click on the tool corresponding to the type of control you want to add. For example,
To create a checkbox, click on the Checkbox tool.
2. Click in the form creation grid where you want to position the corner
upper left of the control. Click once to create a standard size control, or
Click on the tool and drag the mouse pointer in the form creation grid.
to create a custom size control.
3. If you have enabled the Use Assistants control option and the control you want
Pleasure is associated with an Assistant, who starts and guides you throughout the process of
configuration of the control.
4. If you do not position the control perfectly, you can move it by doing as
suit
1. Click on the control to select it.
2. Place the mouse pointer over the control so that it turns into an arrow.
cruciform
3. Click on the control and drag it to the desired location.
If you are using a Control Assistant, it may contain a procedure to link the control to
a field. Failing that, this procedure creates an independent control. If, by its type, the control is in
to display data (for example, a text box or a checkbox), you need to enter
the name of a field or an expression in the property area of the controlSource control for the
the latter can display data. To display the properties of a control, select the control
and press F4.
In Microsoft Office Access 2007, a Yes/No field stores only two values: Yes or No.
No. If you use a text box to display a Yes/No field, the value shows -1
for Yes and 0 for No. These values are not understandable for most users,
this is why Office Access 2007 provides them with check boxes, option boxes and
the toggle buttons to be used to display and enter Yes/No values. These controls provide
a graphical representation of the Yes/No value that is easy to use and read.
The following illustration shows these three controls and their way of representing the values Yes
and No. The Yes column displays the control as it appears when activated, the No column
display the control as it appears when deactivated.
23
Understanding option groups
If a group of options is linked to a field, only the group frame is linked to it; the controls
Contents within the frame are excluded. Rather than defining the propertySource control for
for each control in the options group, set their propertyValue to a number
significant for the field to which the framework is linked. When you select a group of options,
Access defines the value of the field linked to the option group based on the value of the PropertyValue.
control of the selected option.
The value of a group of options can only be numeric. Access stores this number in the
underlying table. You can also set a group of options on an expression or the
make independent. You can use an independent group of options in a box of
custom dialogue to accept user input and execute the associated action.
Checkboxes are commonly used for Yes/No fields, the same goes for
the option boxes or toggle buttons used for option groups. However, it does not
This is just a simple recommendation, you can use the three controls for all these purposes.
You can quickly create a group of options using the Options Group Assistant.
First of all, you need to know if you want to store the value of the option in a table. If
In this case, you need to have a field with a Numeric data type for this purpose.
2. In the Creation tab, in the Controls group, check that Use Control Wizards
is selected.
Although nothing obliges you to do so, it is recommended to give the options group a new
more significant name. This operation does not change the label displayed next to the group
of options, but it is easier to refer to them in the expressions or macros.
1. Make sure that the options group is selected by clicking on the group frame.
2. If the properties sheet is not already visible, press F4 to display it.
3. Type a new name in the property name field of the options group.
24
3. Add a new option to an existing option group
You can add options to a group, based on your needs. You can either
create a new control in the group, or cut an existing control from another
location on the form to paste it in the group.
2. Click on the option group frame to select it, then drag the handles of
sizing of this framework to insert the new option.
1. In the Controls group on the Design tab, click on the type of control to
add (Checkbox) Option case Toggle button ).
Move the pointer to position it within the options group frame.
frame color changes to indicate that the new control is integrated into the
group of options.
3. Click here to place the control in the group.
It is not enough to drag a control to a group of options to integrate it there. You must
cut it and paste it into the group so that it becomes an option.
3. Select the option group by clicking on the frame that surrounds the group.
4. Under the Home tab, in the Clipboard group, click on Paste.
You will likely need to move the control and its label to align them with the controls.
existing and their labels.
1. Select the control you just added, then press F4 to open the sheet of
associated properties.
2. Note the value of the property ControlValue of the control you have just added.
Depending on your needs, you can keep it, as Access suggests, or modify it.
The text box is the standard control used to display and modify data in
forms and statements. Text areas can contain different types of data, which
can also be used to perform calculations. This article explains how to create and
use a text box and describe some of the most common properties of a text box
important.
25
Add a dependent text area
A simple and quick way to create a linked text area is to drag a field from the
field list panel to the form or report. Access automatically creates a zone of
text associated with the following data type fields:
Text
Memo
Digital
Date/Heure
Currency
Hyperlink
By dragging fields associated with other types of data, you create different types
of controls. For example, if you drag a Yes/No field from the field list panel
When creating a form or a report, Access creates a checkbox. If you drag a field
OLE object to a form or a report, Access creates a dependent object frame, and if you
Drag an Attachment field to a form or report, Access creates an Attachment control.
attached.
1. Open the form or the report in Page mode or in Creation mode by clicking on it with the
right-click in the navigation panel and then click on the desired mode.
2. Under the Create tab, in the Tools group, click on Add Existing Fields.
3. In the Fields list pane, expand the table containing the field to bind to the text box.
4. Drag the field from the field list pane to the report or form.
An independent text box is not attached to any table or query field. You
you can use a separate text box to display the results of a calculation or to
accept an input that you do not wish to store directly in a table. Adding a
Independent text zone proves to be simpler in Creation mode.
3. Place the cursor where you want the text box to appear in the form.
or the state, then click to insert the text box.
Note: Access places a label to the left of the text box. Therefore, plan for it.
place to the left of the pointer for this label, even if you can reposition it later
the label and the text area. You can remove the label by clicking on it and
pressing Delete.
26
There is another way to create an independent text area: first create a text area.
dependent text by dragging a field from the field list pane to the form or
the state, then delete the value of its Source control property. If you do this
operation in Creation mode, the text area will display the mention 'Independent' instead of the
field name. In Page mode, the text area will no longer display data and will be empty.
3. Place the pointer where you want to place the text box in the form
or the state, then click to insert the text box.
4. Perform one of the following operations:
Place the cursor in the text area, then type an expression that calculates a total.
Select the text area, press F4 to display the properties sheet, and then type.
the expression in the propertySource control area. To create the expression using the
Expression generator, click on in relation to the property zone Source control.
5. Save the form or the state, then switch to Form mode or Report mode to
check the results.
Remarks
Office Access 2007 provides you with two list controls, the list box and the combo box.
drop-down list.
List boxes and drop-down list boxes can constitute dependent controls or
independent. These controls can search for values in a fixed list that you have
typed, or values in a table or a query. To create a list box or a box of
dependent drop-down list searching for values in a table or a query, check that
the form is based on a data source that includes a foreign key field or
a field Choice List. This is how you can create relationships to link the data
in the list box or the drop-down list to the data in the form.
28
2. Under the Creation tab, in the Controls group, check that Use Control Wizards
is selected.
Depending on your choice, the List Zone Assistant or the Dropdown List Zone Assistant
start.
5. When the Assistant asks you how you want to obtain the values for the control,
perform one of the following operations:
If you want to display the current data in a record source, click
I want the list box/drop-down list to search for values in
a table or query.
Si vous voulez afficher une liste fixe de valeurs qui changeront rarement, cliquez surJe
you will type the desired values.
If you want the control to perform a search rather than play the role of a
data entry tool, click on Find a record in my
form based on the value I selected in the list box/list box
rolling. This is how the system creates an independent control with a macro
incorporated which performs a search based on the value entered by the user.
6. Follow the instructions to specify how to display values.
7. If you selected one of the first two options on the first page of the Assistant,
This one asks you what you want Access to do when you select a
value. Perform one of the following operations:
To create an independent control, click on Save the value for use
Thus, Access retains the selected value as long as the user does not
modifie pas ou tant qu'il ne ferme pas le formulaire. Cependant, Access ne l'inscrit pas
on a table.
To create a dependent control, click on Store this value in this field
select the field you want to link the control to.
8. Click the Next button and type a label for the control. This label will be
displayed in view of the control.
9. Click Finish.
1. Create a Choice List field in a table. The Choice List field you create can
contain a single or multiple values.
Access automatically creates a dropdown list area for the Choice List field.
29
In Creation mode, open a form based on a data source
including the Choice List field.
2. If the field list pane does not appear, press ALT+F8 to display it.
3. Double-click on the Choice List field or drag it from the list panel.
champ towards the form. Access automatically creates a dropdown list.
dependent on the field.
Tip: To change a drop-down list area to a list area (or vice versa), click
Right-click on the control, select Replace in the context menu, then
click on the desired control type.
Avec le formulaire ouvert en mode Création, assurez-vous que la zone de liste ou la zone de liste
The dropdown is enabled, then press F4 to open the properties sheet for this control.
Perform one of the following operations:
Change the sorting order in a list box or a drop-down list If you have
used an Assistant to create the list box or drop-down list, Access sorts
automatically the rows that make up the list based on the first visible column. If
you want to specify a different sorting order or if you have set the propertyContent
control over a recorded request, use the following procedure:
Click on the Data tab, then click on the Content property area.
In the Data tab of the properties sheet, click on to open the
Query generator.
In the Trip line for the column to sort, specify your sorting order.
In the property area, Linked column of the list box or drop-down list area, specify
a name that corresponds to the position of the column in the list box or list area
scrolling. For example, type 1 to link the first column to the specified underlying field
in the propertySource control. Include the hidden columns when you count the
columns.
If you set the Column property to 0, Access saves the list index instead of the
value of one of the columns. This is particularly useful for storing a sequence of numbers
rather than the list of values.
Let's take the example of a two-column dependent dropdown area, one titled
Supplier number with a width of 0.5 inches and the other titled SupplierName with a width of 2.
inches. The supplier number column is the first column of the list, thus the property
Column widths are set to 0.5"; 2". To hide the latter, set the property
Column widths 0"; 2". The supplier column No. constitutes the dependent column.
even if it is masked.
Note: In a drop-down list area, the first visible column is displayed in the
text box part of the drop-down list when the list does not appear. For example, the
the SupplierName column in the previous example is displayed because the Supplier No. column is
masked. If that were not the case, it would be displayed in place of the SupplierName column.
30
Add column headers to a dropdown list in a form
In the property zone, under Column headers, click Yes to display the headers
of columns. The headers of the dropdown areas only appear if the list is
open.
If the drop-down list or the list box depends on a record source, Access
use the field names from the source record as column headers. If the area
the dropdown list or the list box depends on a list of fixed values, Access uses the
first data elements of the value list (propertyContent) as headers of
columns, knowing that n = the number defined in the property Number of columns.
Désactiver le remplissage en cours de frappe pour une zone de liste déroulante dans un
form
In the property area, expand Auto, click on No.
When the propertyAuto extend is set to No, you must select a value in
the list or type it out completely.
The width of the list box area of a drop-down list can be larger, but
never less than the text area part. The default setting (Auto) assigns to the area of
list the width of the text area of the dropdown list.
Define the maximum number of lines that a dropdown list can display in a
form
In the property zone, type a number in the displayed lines.
If the number of actual rows exceeds the number defined in the property Displayed rows,
A vertical scrollbar appears in the dropdown list area.
Limit the drop-down list entries to items from a part of a list area.
the dropdown list on a form
In the ownership area, limit to list, click on Yes.
If the first column displayed in a dropdown list is not the column
linked, Access limits entries to the list items even if the property limits to
the list is defined as No.
If the property Limit to list is set to No and you type a value that does not
The number does not fit in the list, if the dropdown area is dependent, the entry is stored.
in the underlying field but is not added to the list. To add new
for entries to the list, use the property on absence in the list and the absence event
in the list.
31
4. Save your work
As soon as you save the structure of your form, you can also run the form.
often as you wish. If the structure does not change, the data is updated each time that
you display the form. If your needs change, you can modify the structure of the form,
or create a new form based on the original.
2. If the form is untitled, type a name in the form Name box, then click on
OK.
Presentation of sub-forms
A sub-form is a form inserted into another form. The base form is called
main form and the form it contains, sub-form. A form/sub-form combination.
form is sometimes referred to as hierarchical form or parent/child form.
Sub-forms are particularly useful when you want to display the data of
tables or queries that have a one-to-many relationship.. For example, you can create a form
containing a sub-form to display data from a Categories table and data from a table
Products. The data in the Categories table represent the 'one' side of the relationship, while the
data from the Products table represents the 'many' side of the relationship. In other words, each
category can have multiple products.
The main form displays the data from the 'one' side of the relationship.
The sub-form displays the data on the 'many' side of the relationship.
In this type of form, the main form and the sub-form are linked, so that the sub-
The form only displays the records associated with the active record of the main form.
Thus, when the main form displays the Beverages category, the sub-form displays
only the products of this category. If the form and the subform were not linked, the
The sub-form would present all products, not just those in the Beverages category.
The following table defines some terms related to subforms. Even though Access handles most
details related to the use of the procedures described in this article, it is useful to know what is happening
"behind the scenes" to make subsequent changes.
Term Definition
Control that allows you to embed a form within another form. You can
compare the control of a subform to a "view" of another object in your database
Control of
data, whether it is another form, a table, or a query. The control of
sub-form
The sub-form has properties that allow you to link the displayed data.
in the control of the data of the main form.
Property of the subform control that indicates the object being displayed in the
source control.
Simple display of data in rows and columns, in the manner of a
spreadsheet. The subform control displays a datasheet when
Sheet of
its source object is a table or a query, or even a form whose property
data
The default display is set to Data Sheet. In these cases, the sub-
The form is sometimes called a data sheet and not a sub-form.
Link Property
Property of the sub-form control that indicates the field(s) of the sub-
the fields
forms that are linked to the main form.
children
PropertyLink
Subform control property that indicates the field(s) of the form
the fields
main ones that are linked to the sub-form.
fathers
To optimize results, start by establishing all relationships. Access can thus create
automatically the links between the sub-forms and the main forms. To display or
modify the existing relationships between the tables in your database or to create new ones,
Under the Advanced Tools tab, in the Analyze group, click on Relationships.
When a subform control has a source object of a form, it contains the fields that you
place in this form, and it can be displayed as a standard form, continuous form or
Data sheet. Basing a subform on a form object allows you to add fields.
calculated in the sub-form, for example, [Quantity] * [Unit price].
You can also insert a data sheet into a form by creating a sub-control.
Form whose source object is a table or a query. A datasheet cannot be
customized like a sub-form; for example, you cannot add a calculated field to
a data sheet. However, you can create a subform based on a form that
contains a calculated field, then set the default Display property of this form to Sheet
data. You thus obtain a sub-form of the data sheet type that contains a field
calculated.
This procedure allows you to create a form/subform combination using the Wizard.
Form.
33
1. Under the Create tab, in the Forms group, click on More Forms, then on
Assistant Form .
2. In the dropdown list Tables/Queries on the first page of the Assistant, select a
table or a query. In this example, to create a Categories form that
present the products of each category in a subform, select Table:
Categories (the 'one' side of the one-to-many relationship).
3. Double-click on the fields of this table or query that you want to include.
4. On the same page of the Assistant, select another table or query from the dropdown list.
Tables/Queries. For this example, select the Products table (the 'many' side of the
one-to-many relationship.
Double-click on the fields of this table or query that you want to include.
6. When you click Next, assuming you have correctly configured the relationships.
Before starting the Assistant, it asks you the following question: How would you like to...
Do you display your data? (that is, based on which table or query). In the context
from this example, to create the Categories form, click on Categories. The Assistant
displays a reduced image of the form. The area in the lower part of the form
represents the sub-form.
7. At the bottom of the Assistant's page, select the option Form with sub-form(s) and
then Next.
8. On the page What layout do you want for your subform? of the Assistant,
click on Table or Data sheet according to the desired layout for your sub-
form. The two styles display the data of the sub-form in the form of rows and
columns, but the tabular layout is more customizable. You can add some
color, graphs and other formatting elements, while a data sheet
is more compact, just like the Datasheet view of a table. When you have
make your selection, click on Next.
9. On the page What style do you want? of the Assistant, select a formatting style
for the form. If you chose Tabular on the previous page, the formatting style
choose is also applied to the sub-form. Once you have made your selection, click on
Following.
10. On the last page of the Assistant, enter the titles of the forms. Access names the forms.
based on the entered titles and create the sub-form label according to the assigned title
this one.
Also indicate on this page if you want to open the form in Form mode in order to
be able to display or modify the information or if you want to open it in Creation mode in order to
modify your design. Once you have made your selection, click Finish.
Access creates two forms: one for the main form including the subform control.
and one for the sub-form itself.
Follow this procedure if you have two existing forms and want to use one of them.
as a sub-form of the other form.
In Creation mode, open the form that you want to use as the main form.
2. In the Controls group of the Create tab, if the Use Control Wizards tool is
selected, click on it to select.
34
Access adds a subform control to the main form and binds the control to the form that
you have dragged from the navigation pane. Access also tries to link the subform to
main form, depending on the relationships that have been defined in your database. If Access
is not able to link the sub-form to the main form, properties Link fields
children and linking the parent fields of the sub-form controls are empty, and you need to define them
manually by proceeding as follows:
The dialog box for the Link Editor of subform fields appears.
5. In the dropdown lists Parent fields and Child fields, select the fields to which
You want to link the forms. If you are unsure about which fields to choose, click on
Suggest for Access to try to determine the linkage fields. When you are done,
click on OK.
If you do not see the field you wish to use to link the forms, you may need to
modify the source of the registration of the child form or the child form so that the field of
the liaison is there. For example, if the form is based on a request, you must ensure that the
the linking field is present in the query results.
6. Save the main form and switch to Form mode to check that the form
works as expected.
If you want to make changes to the structure of a subform while you are using
main form in Creation mode, you can open the sub-form in its own
window
35
IV. IMPORTER, ADD OR LINK TO
DATA FROM AN EXTERNAL SOURCE
If you have data recorded in another program, you can import it into a
new table or add them to a table in Access. You can also use in Access the
data that your collaborators keep in other programs by creating a link to this data.
Whatever the case may be, manipulating data from an external source resembles a
child's play in Access. Indeed, you can import data from a spreadsheet.
Excel, from a table of another Access database, from a Windows SharePoint Services 3.0 list or
many external sources. The procedure below is a good starting point, even if the
the process varies slightly depending on the source used.
For example, if you import data from an Excel spreadsheet, click on Excel. If you do not
If you cannot find the desired type of program, click on More.
Note: If the appropriate format type does not appear in the Import group, start the
program in which you created the data, then use it to save the data in a
current file format (delimited text file, for example) to be able to import this data into
Access.
2. In the External Data dialog box, click Browse to search for the file.
source data or type the full path of this file in the Filename field.
3. Click on your chosen option (all programs allow you to import some
data, some also allowing to add or link to them) specify the mode and
the storage location of the data in the active database. You can create
a table that uses the imported data, add the data to an existing table (with
certain programs) or create a linked table that contains a link to the data in the
source program.
4. If an Assistant starts, follow the instructions displayed on the following pages. On the last one
On the Assistant page, click Finish.
If you import objects or link tables from an Access database, the dialog box
Import objects or attach the tables displayed. Select the items of your choice, then
click on OK.
The exact process depends on the operation being performed: importing, adding, or linking data.
Access asks if you want to save the details of the import operation that you
come to execute. If you think you will re-execute this import later,
click on Save the import steps, then enter the details. You will then be able to
repeat the operation later easily by clicking on Imports
recorded in the group Import under the External Data tab. If you do not wish to
to not save the operation details, click on Close.
If you import a table, Access imports the data into a new table, then displays the table.
in the groupTables of the navigation pane. If you add data to a table, it is
added to the table. If you create a link to data, Access creates a linked table in the group
Navigation panel tables.
36