Microsoft Access - Intermediate Day 2: Course Reference Handout
Microsoft Access - Intermediate Day 2: Course Reference Handout
Microsoft Access - Intermediate Day 2: Course Reference Handout
MICROSOFT ACCESS -
INTERMEDIATE
Contact us at Learn iT!
(415) 693-0250
www.learnit.com
DAY 2
MICROSOFT ACCESS
Module 03
Access Table Relationships: Establishing Table Relationships:
Relationships between Access tables are required in order to ■■ From the Database Tools tab, click the
allow queries to extract data from multiple tables into a single Relationships command.
result. Tables relate through a common field in both tables. ■■ Drag the respective tables from the
This common field must follow these guidelines: Navigation Panel into the Relationships
■■ Common fields must be the same data-type (i.e., Text or window.
Number). ■■ Size and organize the tables to your
■■ Common fields must be the same field size (i.e., both be preference.
Long Integer, Integer, etc. for Number fields). ■■ Drag the common relatable field from one
■■ Common fields must use the same data in their respective table to the other table’s relatable field.
fields (i.e., use the same Cust ID values for Customers and ■■ In the Edit Relationship dialog box, click
Sales). Create button.
■■ Common field must be the Primary Key in the One-Side of
the Relationship. Access Relationship Window:
Types of Relationships:
There are three types of relationships you may encounter –
Note:
Access can only work with the first two.
One to One:
A One to One relationship exists when for every record in one
table of the relationship there is only one matching record in the
other table of the relationship. This is specific to the field that
the two tables share.
Note:
Example:
The symbols on the relationship lines represent
For each Customer Number in a Customer’s table there is one that Enforce Referential Integrity has been
matching Customer Number in a Credit Info table used to track checked. With this option active, the “Many”-Side
Customer credit card info. The Primary Key would be attached to to the relationship cannot contain any records that
both of these common fields. have a value in the related field that is not already
entered in One-Side of the relationship (i.e., An
One to Many: order with a CustomerID that is not already entered
A One to Many relationships exists when for every record in one into the Customers table). This option creates more
table of the relationship there may be many matching records security and accuracy for data entry and is highly
in the other table of the relationship. This is specific to the field recommended.
that the two tables share.
Example:
For each Customer Number in a Customer’s table there may be
many matching Customer Numbers in an Orders table used to
track orders that Customers place… as in any ONE customer may
place MANY orders. The Primary Key is attached to the field in
One-Side of this relationship.
Many to Many:
A Many to Many relationship exists when two tables that need
to be related cannot be related because no common field to join
the tables exists. This can be solved be creating another table,
known as a Junction Table, which is then used to indirectly join
the two tables in the Many to Many relationship. (This results in
creating two separate One to Many relationships.)
02
MICROSOFT ACCESS
Module 04
Terms and References:
Query: ■■ To add fields of data to the Query Design Grid in the lower
The Query object of a database is the tool that allows you to pull part of the window, either double-click the fields from the
fields of information from multiple tables of a relational database table field lists above – or – click and drag the fields into the
into a single datasheet. The results of running a query look just grid below. Do this for all fields you want to see in the results
like a table – only the information you see can come from any of your query.
number of individual tables. Queries also allow you to filter out
■■ To see the results of a Select Query either
certain records you do not wish to see, can perform calculations,
click the Datasheet View button or the Run
and perform actions such as automatically updating or deleting
records within a table for you, so you don’t have to. There are button in the Results group of the Ribbon.
several types of queries in Access: Select Queries, Action Queries, ■■ Click the Save button from the Quick
Parameter Queries and Cross Tab Queries to name a few. Access Toolbar – or – use the keyboard
shortcut [CTRL] + [S] to save the query to the
SQL: database.
SQL (Structured Query Language) is essentially the
programming language that a query is written in. Some Access Sorting Query Results:
database designers will work directly in this language when Though the Datasheet view of a query can be sorted the same
creating or modifying a query. If you know the SQL language, way as a table, the Query Design view has an area to include
you can accomplish much more with your queries in Access. multiple field sorting. To sort the records that will appear as the
result of your query before running the query:
Select Query:
■■ Switch to the Design view of your query by clicking
This is the most common of the queries types. Essentially, a
Select Query is simply one in which you have selected various the Design View button on the Ribbon.
fields from different tables of a relational database that you want ■■ Click in the Query Design Grid in the lower part of the
to see together in a single view – called the datasheet view of a window where the Sort Row intersects the field you
query. You can then filter, sort and calculate your results within want to sort by.
the Design View of your select query. ■■ Click the drop-down arrow to the right of the sort
area for the field and select either Ascending or
Descending.
■■ Repeat this for any additional fields you also want to
sort by when using a multiple field sort.
■■ Switch back to the Datasheet view or click the Run
button to see the query’s results.
03
MICROSOFT ACCESS
■■ Click in the Query Design Grid in the lower part of the window where the Criteria Row intersects the field you want to filter by.
■■ Type in the necessary criteria values to filter the data in the field with.
■■ To add more than one criterion to filter by, click in the Or Rows (which includes ALL rows below the Criteria Row – even those that
are not labeled “Or”) and enter the additional criteria as needed.
■■ To apply criteria to more than one field of data at the same time (known as an AND condition) click in the same Criteria Row
containing your other conditions and enter the additional criteria as needed.
■■ View the results of the query by switching to the Design view – or – run the query using the Run button.
04
MICROSOFT ACCESS
Using an Action Query: Importing Data:
To switch from a normal Select Query to one of the Action Data from other files, such as Excel worksheets or delimited text
Queries: files, can be imported into an Access database as a table. You
■■ Begin a new query in Design view. can also import objects from other Access databases such as
existing tables, queries, forms and reports.
■■ Add the tables that contain the fields of data you need for
your Action Query. Importing Objects from another Database:
■■ Select only the fields of data from the table or tables that To import a table, query, form, report or other objects from
you want effected by the specific action of the Action Query another database:
you will be using. ■■ Click on the External Data command tab from top of the
■■ To select one of the Action queries, click on appropriate Ribbon.
button from the Query Type group in the Ribbon. ■■ Select one of the buttons from the Import group of the
■■ RUN the Action query to execute the action by clicking the Ribbon according to the type of data you want to import.
Run button. ■■ In the Import Objects window, select any objects from
the tabs provided that you want to import. Click OK when
finished.
Note:
Note:
You can also link data from a table of one database
Clicking the Datasheet view button will NOT to a table in another database. Instead of selecting
execute the action of an Action Query. You must the Import Tables… from the Get External Data
click the actual Run button instead for an Action window, select Link Tables… and then choose the
Query to execute. database file and tables you want to import with a
link established.
05
MICROSOFT ACCESS
Steps:
■■ View the report in Design View or Layout View
■■ Click on a control (a field) in the Detail section.
■■ Find and click the small somewhat hidden icon that is
represented as a 4-headed arrow inside a box.
■■ On the Arrange tab, click the Remove button.
■■ Click away from all the controls.
■■ Now you can individually size and move any control.
06