Short Notes On MS Access
Short Notes On MS Access
Introduction:
Microsoft Access is a database creation and management program. To understand
Access, you must first understand databases.
In this lesson, you will learn about databases and how they are used.
What is a database?
A database is a collection of data that is stored in a computer system. Databases allow
their users to enter, access, and analyze their data quickly and easily. They're such a
useful tool that you see them all the time. Ever waited while a doctor's receptionist
entered your personal information into a computer, or watched a store employee use a
computer to see whether an item was in stock? If so, then you’ve seen a database in
action.
The easiest way to understand a database is to think of it as a collection of lists. Think
about one of the databases we mentioned above: the database of patient information at
a doctor's office. What lists are contained in a database like this? To start with, there's
a list of patients' names. Then there's a list of past appointments, a list with medical
history for each patient, a list of contact information, and so on.
This is true of all databases, from the simplest to the most complex. For instance, if you
like to bake you might decide to keep a database containing the types of cookies you
know how to make and the friends you give these cookies to. This is one of the simplest
databases imaginable. It contains two lists: a list of your friends, and a list of cookies.
However, if you were a professional baker, you would have many more lists to keep
track of: a list of customers, a list of products sold, a list of prices, a list of orders, and
so on. The more lists you add, the more complex the database will be.
In Access, lists are a little more complex than the ones you write on paper. Access stores
its lists of data in tables, which allow you to store even more detailed information. In
the table below, the People list in the amateur baker’s database has been expanded to
include other relevant information on the baker’s friends.
If you are familiar with other programs in the Microsoft Office suite, this might remind
you of Excel, which allows you to organize data in a similar way. In fact, you could
build a similar table in Excel.
Why use a database?
If a database is essentially a collection of lists stored in tables and you can build tables
in Excel, why do you need a real database in the first place? While Excel is great at
storing and organizing numbers, Access is far stronger at handling non-numerical
data, like names and descriptions. Non-numerical data plays a significant role in almost
any database, and it's important to be able to sort and analyze it.
However, the thing that really sets databases apart from any other way of storing data
is connectivity. We call a database like the ones you’ll work with in Access a relational
database. A relational database is able to understand how lists and the objects within
them relate to one another. To explore this idea, let's go back to the simple database
with two lists: names of your friends, and the types of cookies you know how to make.
You decide to create a third list to keep track of the batches of cookies you make and
who they’re for. Because you're only making cookies you know the recipe for and
you're only going to give them to your friends, this new list will get all of its information
from the lists you made earlier.
See how the third list uses words that appeared in the first two lists? A database is
capable of understanding that the Dad and Oatmeal cookies in the Batches list are the
same things as the Dad and Oatmeal cookies in the first two lists. This relationship
seems obvious, and a person would understand it right away; however, an Excel
workbook wouldn’t.
Excel would treat all of these things as distinct and unrelated pieces of information. In
Excel, you'd have to enter every single piece of information about a person or type of
cookie each time you mentioned it because that database wouldn't be relational like an
Access database. Simply put, relational databases can recognize what a human can: If
the same words appear in multiple lists, they refer to the same thing.
The fact that relational databases can handle information this way allows you
to enter, search for, and analyze data in more than one table at a time. All of these
things would be difficult to accomplish in Excel, but in Access even complicated tasks
can be simplified and made fairly user friendly.
Introduction to Objects
Databases in Access are composed of four objects: tables, queries, forms, and reports.
Together, these objects allow you to enter, store, analyze, and compile data however
you want.
In this lesson, you will learn about each of the four objects and come to understand
how they interact with each other to create a fully functional relational database.
Tables
By this point, you should already understand that a database is a collection of data
organized into many connected lists. In Access, all data is stored in tables, which puts
tables at the heart of any database.
You might already know that tables are organized into vertical columns and
horizontal rows.
In Access, rows and columns are referred to as records and fields. A field is more than
just a column; it’s a way of organizing information by the type of data it is. Every piece
of information within a field is of the same type. For example, every entry in a field
called First Name would be a name, and every entry in field called Street
Address would be an address.
Likewise, a record is more than just a row; it's a unit of information. Every cell in a
given row is part of that row’s record.
Notice how each record spans several fields. Even though the information in each
record is organized into fields, it belongs with the other information in that record. See
the number at the left of each row? It’s the ID number that identifies each record. The
ID number for a record refers to every piece of information contained on that row.
Tables are good for storing closely related information. Let's say you own a bakery
and have a database that includes a table with your customers' names and information,
like their phone numbers, home addresses, and email addresses. Because these pieces
of information are all details on your customers, you’d include them all in the
same table. Each customer would be represented by a unique record, and each type of
information about these customers would be stored in its own field. If you decided to
add any more information—say, a customer's birthday—you would simply create a new
field within the same table.
Forms make entering data easier. Working with extensive tables can be confusing, and
when you have connected tables you might need to work with more than one at a time
to enter a set of data. However, with forms it's possible to enter data into multiple tables
at once, all in one place. Database designers can even set restrictions on individual form
components to ensure all of the needed data is entered in the correct format. All in all,
forms help keep data consistent and organized, which is essential for an accurate and
powerful database.
Queries
Queries are a way of searching for and compiling data from one or more tables.
Running a query is like asking a detailed question of your database. When you build a
query in Access, you are defining specific search conditions to find exactly the data
you want.
Queries are far more powerful than the simple searches you might carry out within a
table. While a search would be able to help you find the name of one customer at your
business, you could run a query to find the name and phone number of every customer
who's made a purchase within the past week. A well-designed query can give
information you might not be able to find just by looking through the data in your tables.
Reports
Reports offer you the ability to present your data in print. If you've ever received a
computer printout of a class schedule or a printed invoice of a purchase, you've seen a
database report. Reports are useful because they allow you to present components of
your database in an easy-to-read format. You can even customize a report's appearance
to make it visually appealing. Access offers you the ability to create a report from
any table or query.
Putting it all together
Even if you have a good idea of how each object can be used, it can initially be difficult
to understand how they all work together. It helps to remember that they all work with
the same data. Every piece of data a query, form, or report uses is stored in one of
your database tables.
Forms allow you to both add data to tables and view data that already exists.
Reports present data from tables and also from queries, which then search
for and analyze data within these same tables.
These relationships sound complicated, but in fact they work together so well and
naturally that we often don't even notice when we're using connected database objects.
Have you ever used an electronic card catalog to search for a book at the library?
Chances are, you entered your search into something that looks like this:
When you performed your search, you were entering your search terms into a form that
then created and ran a query based on your request. When the query finished searching
the database's tables for records that matched your search, you were shown
a report that drew information from the query and the related tables—in this case, a
list of books matching your search terms. You could represent the connections between
the objects like this:
Let's say instead of using these tools you had to search within a giant table containing
every book in the library system. The relevant records would likely be spread out across
many tables: a table for book titles and descriptions, a table containing information on
which books are checked in or out, and a table with each branch of the library, just to
name a few.
You'd have to search at least three tables just to find a book, learn its location, and see
whether it's checked in! It's easy to imagine how difficult it could become to find the
right book. If you weren't careful, you might even mess something up by accidentally
deleting or editing a record. It's easy to see how the database objects make this search
much more manageable.
A relational database, is a database that is able to understand how different sets of
data relate to one another. Situations like the example above are exactly why people
find relational databases so useful. Without a relational database, what should be a
simple task—searching for a book and seeing if it's checked in and where—becomes
incredibly complicated and time consuming. Knowing how to use the four Access
objects can make even complicated tasks fairly user friendly.
Getting Started in Access
Whenever you're learning a new program, it's important to familiarize yourself with the
program window and the tools within it. Working with Access is no different. Knowing
your way around the Access environment will make learning and using Access much
easier.
In this lesson, you will familiarize yourself with the Access environment, including
the Ribbon, Backstage view, Navigation pane, Document Tabs bar, and more. You
will also learn how to navigate with a navigation form, if your database includes one.
Access 2016 uses the Ribbon to organize commands, just like in Access 2013 and
2010. If you've used these versions before, Access 2016 will feel familiar. But if you
are new to Access or have more experience with older versions, you should first take
some time to become familiar with the Access 2016 interface.
Click the buttons in the interactive below to become familiar with the Access interface.
2. The Ribbon will be minimized. Click a tab to make the Ribbon reappear. It will
disappear again when not in use.
3. To maximize the Ribbon, click a tab, then click the pin icon in the lower-right
corner. The Ribbon will appear at all times.
Using the Tell me feature
If you're having trouble finding command you want, the Tell me feature can help. It
works just like a regular search bar: Type what you're looking for, and a list of options
will appear. You can then use the command directly from the menu without having to
find it on the Ribbon.
Note that the Save command only saves the current open object. In addition,
the Undo command will not undo certain actions, like adding a record. Pay close
attention to your information when using the Undo command to make sure it has the
desired effect.
Backstage view
Backstage view gives you various options for saving, opening, and printing your
database.
To access Backstage view:
1. Click the File tab on the Ribbon.
2. Backstage view will appear.
Click the buttons in the interactive below to learn more about using Backstage view.
2. The Navigation pane will be minimized. Click the double arrow again to
maximize it.
If you want to make the Navigation pane smaller without fully minimizing it, you
can resize it. Simply click and drag the right border of the Navigation pane. When it is
the desired size, release your mouse.
To further customize the appearance of the Navigation pane, you can minimize
groups of objects you don't want to see. Simply click the upward double arrow next
to the group name. To show a group, click the downward double arrow.
Generally, navigation forms include only the objects a typical user will need to work
with fairly regularly, which is why your navigation form may not include every single
form, query, or report. This makes it easier to navigate the database. By hiding tables
and rarely used forms, queries, and reports, it also reduces the chance of the database
being damaged by users accidentally editing or deleting necessary data.
For this reason, it's important to ask your database designer or administrator before
working with objects that are not available in your navigation form. Once you have the
go-ahead, you can simply maximize the Navigation pane and open the objects from
there.
1. Click New.
2. Several templates will appear below the Blank desktop database option. You
can also click a suggested search to find templates or use the search bar to
find something more specific.
3. Select a template to review it.
3. Click Browse.
4. The Open dialog box will appear. Locate and select the database, then
click Open.
5. One or more warning messages may appear when you open your database. If
the database contains customized functions, a yellow bar with a security
warning may appear below the Ribbon. If you trust the source of your database,
click Enable Content for your database to display correctly.
6. After enabling all content in the database, you may see a message asking if you
want to make the database a Trusted Document. Click Yes if you would like
all content to be automatically enabled each time you open the database.
You may also be prompted to sign in to the database. Select your name from the login
list. If your name does not appear, click Add User to enter your information.
To close a database:
1. Select the File tab to go to Backstage view.
2. Select Close.
If you have any unsaved objects, a dialog box will appear for each one asking if you
would like to save it. Select Yes to save the object, No to close it without saving,
or Cancel to leave your database open.
Working with objects
It's helpful to think of your database as a large binder or folder in which you store your
data. The data itself is contained in database objects. Access treats each of these objects
as separate documents, which means you will have to open and save them individually
in order to work with them.
You may have noticed that this lesson contains no instructions for saving a database.
This is because you cannot save an entire database at once. Rather, you must
individually save the objects contained within the database.
To open an object:
1. In the Navigation pane, locate and double-click the desired object.
By default, the most recently opened object will appear in the main window as
the current object. To view another open object, click its tab in the Document Tabs
bar.
Saving objects
You'll need to save any changes you make to each object before closing your database.
Remember, saving early and often can prevent your work from being lost. However,
you will also be prompted to save any unsaved work when you attempt to close your
database.
To save a new object:
1. Select the object you want to save by clicking its tab in the Document Tabs
bar.
2. Click the Save command on the Quick Access Toolbar, or press Ctrl+S on
your keyboard.
3. The first time you save an object, you will be prompted to name it. Enter the
desired object name, then click OK.
4. The object will be saved. Click the Save command again to save any changes
to the object.
To close an object:
1. Select the object you want to close, then click the X to the right of the Document
Tabs bar.
2. If there are any unsaved changes to the object, you will be prompted to save it.
Select Yes to save, No to close it without saving your changes, and Cancel to
leave the object open.
You can also close an object by right-clicking its tab on the Document Tabs bar and
selecting Close. Select Close All to close all open objects.
To rename an object:
1. If the object you want to rename is open, close it.
2. In the Navigation pane, right-click the desired object, then select Rename.
3. Type the new object name, then press Enter on your keyboard.
4. The table will open and appear as a tab in the Document Tabs bar.
Understanding tables
All tables are composed of horizontal rows and vertical columns, with small rectangles
called cells in the places where rows and columns intersect. In Access, rows and
columns are referred to as records and fields.
A field is a way of organizing information by type. Think of the field name as a
question and every cell within that field as a response to that question. In our example,
the Last Name field is selected, which contains all the last names in the table.
A record is one unit of information. Every cell on a given row is part of that row's
record. In our example, Quinton Boyd's record is selected, which contains all of the
information related to him in the table.
Each record has its own ID number. Within a table, each ID number is unique to its
record and refers to all of the information within that record. The ID number for a record
cannot be changed.
Each cell of data in your table is part of both a field and a record. For instance, if you
had a table of names and contact information, each person would be represented by a
record, and each piece of information about each person—name, phone number,
address, and so on—would be contained within a distinct field on that record's row.
Click the buttons in the interactive below to learn how to navigate a table.
Navigating within tables
The bar at the bottom of the table contains many commands to help you search or scroll
through records.
To navigate through records in a table, you can use the up and down arrow
keys, scroll up and down, or use the arrows in the Record Navigation
bar located at the bottom of your table.
You can create a new record with the new (blank) record command on
the Record Navigation bar.
You can find any record in the currently open table by searching for it using
the record search box. Place your cursor in the search box, type any word that
appears in the record you want to find, and press the Enter key.
To navigate between fields, you can use the left and right arrow keys or scroll left
and right.
Adding records and entering data
Entering data into tables in Access is similar to entering data in Excel. To work with
records, you'll have to enter data into cells. If you need help entering data into records,
you might want to review our Cell Basics lesson from our Excel 2016 tutorial.
To add a new record:
There are three ways to add a new record to a table:
In the Records group on the Home tab, click the New command.
On the Record Navigation bar at the bottom of the window, click the New
record button.
Sometimes when you enter information into a record, a window will pop up to tell you
that the information you've entered is invalid. This means the field you're working with
has a validation rule, which is a rule about the type of data that can appear in that field.
Click OK, then follow the instructions in the pop-up window to re-enter your data.
To save a record:
Access is designed to save records automatically. After you enter a record, you can
either select a different record or close the object, and Access will save the record.
However, in certain situations you many want to save a record manually. For example,
if you needed to edit an existing record, you could save the record to ensure your
changes are saved.
1. Select the Home tab, and locate the Records group.
2. Click the Save command. The record will be saved.
Editing records
To quickly edit any record within a table, you can click it and type your changes.
However, Access offers you the ability to find and replace a word within multiple
records and delete records entirely.
To replace a word within a record:
You can edit multiple occurrences of the same word by using Find and Replace, which
searches for a term and replaces it with another term.
1. Select the Home tab, and locate the Find group.
2. Select the Replace command. The Find and Replace dialog box will appear.
3. In the Find What: field, type the word you want to find, then in the Replace
With: field type the word you want to replace the original word. In our example,
we'll find instances of the word Fall and replace it with Autumn.
4. Click the Look In: drop-down arrow to select the area you want to search.
Select Current Field to limit your search to the currently selected field.
Select Current Document to search within the entire table.
5. Click the Match: drop-down arrow to select how closely you'd like results to
match your search. Select Any Part of Field to search for your search term in
any part of a cell. Select Whole Field to search only for cells that match your
search term exactly. Select Beginning of Field to search only for cells that start
with your search term.
8. Access will move to the next instance of the text in the object. When you are
finished replacing text, click Cancel to close the dialog box.
The Replace All option is powerful, but it may actually change some things you don't
want to change. In the example below, the word fall did not refer to the season, so
replacing it with Autumn would be incorrect. Using the normal Replace option allows
you check each instance before replacing the text. You can click Find Next to skip to
the next instance without replacing the text.
To delete a record:
1. Select the entire record by clicking the gray border on the left side of the
record.
2. Select the Home tab and locate the Records group.
3. Click the Delete command.
To resize a row:
1. Place your cursor over the bottom gridline in the gray area to the left of the
row. Your mouse will become a double arrow.
2. Click and drag the gridline downward to increase the row height or upward to
decrease the row height, then release the mouse. The row height will be
changed.
Hiding fields
If you have a field you don't plan on editing or don't want other people to edit, you
can hide it. A hidden field is invisible but is still part of your database. Data within a
hidden field can still be accessed from forms, queries, reports, and any related tables.
To hide a field:
1. Right-click the field title, then select Hide Fields.
2. Select a color from the drop-down menu, or select No Color to remove the
alternate row color.
The Datasheet Formatting dialog box offers several advanced formatting options,
including the ability to modify background color, gridline color, and border and line
style. It even includes the ability to view a sample table with your formatting choices,
so play around with the various formatting options until you get your table looking the
way you want it.
2. Click the Home tab on the Ribbon, and locate the Sort & Filter group.
3. Sort the field by selecting the Ascending or Descending command.
4. The table will now be sorted by the selected field.
5. To save the new sort, click the Save command on the Quick Access Toolbar.
After you save the sort, the records will stay sorted this way until you perform another
sort or remove the current one. To remove a sort, click the Remove Sort command.
Filtering records
Filters allow you to view only the data you want to see. When you create a filter, you
set criteria for the data you want to display. The filter then searches all of the records
in the table, finds the ones that meet your search criteria, and temporarily hides the ones
that don't.
Filters are useful because they allow you to focus in on specific records without being
distracted by the data you're uninterested in. For instance, if you had a database that
included customer and order information, you could create a filter to display only
customers living within a certain city or only orders containing a certain product.
Viewing this data with a filter would be far more convenient than searching for it in a
large table.
In our examples and explanations, we will be applying filters to tables. However, you
can apply filters to any Access object. The procedure is largely the same.
To create a simple filter:
1. Click the drop-down arrow next to the field you want to filter by. We will filter
by city because we want to see a list of customers who live in a certain city.
2. A drop-down menu with a checklist will appear. Only checked items will be
included in the filtered results. Clicking Select All will select or deselect
everything at once. In our example, we'll deselect everything except Cary.
3. Click OK. The filter will be applied. Our customers table now displays only
customers who live in Cary.
Toggling your filter allows you to turn it on and off. To view the records without the
filter, click the Toggle Filter command. To restore the filter, click it again.
Creating a filter from a selection
Filtering by selection allows you to select specific data from your table and find data
that is similar or dissimilar to it. For instance, if you were working with a bakery's
database and wanted to search for all products whose names contained the
word chocolate, you could select that word in one product name and create a filter with
that selection. Creating a filter with a selection can be more convenient than setting up
a simple filter if the field you're working with contains many items. You can choose
from the following options:
Contains includes only records with cells that contain the selected data.
Does Not Contain includes all records except for those with cells that contain
the selected data.
Ends With includes only records whose data for the selected field ends with
the search term.
Does Not End With includes all records except for those whose data for the
selected field ends with the search term.
To create a filter from a selection:
1. Select the cell or data you want to create a filter with. We want to see a list of
all of our products that contain the word chocolate in their names, so we'll select
the word Chocolate in the Product Name field.
2. Select the Home tab on the Ribbon, locate the Sort & Filter group, and click
the Selection drop-down arrow.
3. Select the type of filter you want to apply. We'll select Contains
"Chocolate" because we want to see records that contain the
word Chocolate anywhere in the field.
4. The filter will be applied. Our table now displays only products with the
word Chocolate in their names.
2. In the drop-down menu, hover your mouse over Text Filters. From the list that
appears, select the way you want the filter to match the term you enter. In this
example, we want to view only records whose notes indicate the order was
placed for a party. We'll select Contains so we can search for records that
contain the word party.
3. The Custom Filter dialog box will appear. Type the word you want to use in
your filter.
3. The Custom Filter dialog box will appear. Type the number or numbers you
want to use in your filter. We'll type 5 so the filter will show us only menu items
that cost $5 or less.