Learn Microsoft Access
Learn Microsoft Access
Learn Microsoft Access
Tutorial
Microsoft Access is a Database Management System
(DBMS) from Microsoft that combines the relational
Microsoft Jet Database Engine with a graphical user
interface and softwaredevelopment tools. It is a part of the
Microsoft Office suite of applications, included in the
professional and higher editions. This is an introductory
tutorial that covers the basics of MS Access.
FREE EBOOKs
Thank you!
TABLE OF CONTENTS
1. Ms Access - Overview
2. Ms Access - RDBMS
3. Ms Access - Objects
4. Ms Access - Create Database
5. Ms Access - Data Types
6. Ms Access - Create Tables
7. Ms Access - Adding Data
8. Ms Access - Query Data
9. Ms Access - Query Criteria
10. Ms Access - Action Queries
11. Ms Access - Create Queries
12. Ms Access - Parameter Queries
13. Ms Access - Alternate Criteria
14. Ms Access - Relating Data
15. Ms Access - Create Relationships
16. Ms Access - One-To-One Relationship
17. Ms Access - One-To-Many Relationship
18. Ms Access - Many-To-Many Relationship
19. Ms Access - Wildcards
20. Ms Access - Calculated Expression
21. Ms Access - Indexing
22. Ms Access - Grouping Data
23. Ms Access - Summarizing Data
24. Ms Access - Joins
25. Ms Access - Duplicates Query Wizard
26. Ms Access - Unmatched Query Wizard
27. Ms Access - Create Form
28. Ms Access - Modify Form
29. Ms Access - Navigation Form
30. Ms Access - Combo BOx
31. Ms Access - SQL View
32. Ms Access - Formatting
33. Ms Access - Controls & Properties
34. Ms Access - Reports Basics
35. Ms Access - Formatting Reports
36. Ms Access - Built-In Functions
37. Ms Access - Macros
38. Ms Access - Data Import
39. Ms Access - Data Export
Do you want to learn the really advanced content that we
couldn’t include in this eBook?
1. Excel-based Production Scheduling System CLICK HERE
2. Dose For Excel Add-in CLICK HERE
3. Aplica Excel Contable (view mobile) CLICK HERE
Ms Access - Overview
Microsoft Access is a Database Management System
(DBMS) from Microsoft that combines the relational
Microsoft Jet Database Engine with a graphical user
interface and softwaredevelopment tools. It is a member of
the Microsoft Office suite of applications, included in the
professional and higher editions.
ARCHITECTURE
• Access calls anything that can have a name an
object. Within an Access desktop database, the main
objects are tables, queries, forms, reports, macros,
data macros, and modules.
• If you have worked with other database systems on
desktop computers, you might have seen the term
database used to refer to only those files in which
you store data.
• But, in Access, a desktop database (.accdb) also
includes all the major objects related to the stored
data, including objects you define to automate the
use of your data.
Ms Access - RDBMS
Microsoft Access has the look and feel of other Microsoft
Office products as far as its layout and navigational aspects
are concerned, but MS Access is a database and, more
specifically, a relational database.
DATA MANIPULATION
Working with data in RDBMS is very different from
working with data in a word processing or spreadsheet
program.
DATA CONTROL
Spreadsheets and word processing documents are great for
solving single-user problems, but they are difficult to use
when more than one person needs to share the data.
Ms Access - Objects
MS Access uses “objects" to help the user list and organize
information, as well as prepare specially designed reports.
When you create a database, Access offers you Tables,
Queries, Forms, Reports, Macros, and Modules. Databases
in Access are composed of many objects but the following
are the major objects −
• Tables
• Queries
• Forms
• Reports
TABLE
Table is an object that is used to define and store data. When
you create a new table, Access asks you to define fields
which is also known as column headings.
QUERY
An object that provides a custom view of data from one or
more tables. Queries are a way of searching for and
compiling data from one or more tables.
REPORT
Report is an object in desktop databases designed for
formatting, calculating, printing, and summarizing selected
data.
MACRO
MODULE
Module is an object in desktop databases containing custom
procedures that you code using Visual Basic. Modules
provide a more discrete flow of actions and allow you to
trap errors.
Ms Access - Create
Database
In this chapter, we will be covering the basic process of
starting Access and creating a database. This chapter will
also explain how to create a desktop database by using a
template and how to build a database from scratch.
Let us enter project in the search box and press Enter. You
will see the database templates related to project
management.
Select the first template. You will see more information
related to this template.
Now, click the Navigation pane on the left side and you will
see all the other objects that come with this database.
Click the Projects Navigation and select the Object Type in
the menu.
You will now see all the objects types — tables, queries, etc.
Here are some of the most common data types you will find
used in a typical Microsoft Access database.
Type of
Description Size
Data
Text or combinations of text
and numbers, including
Up to 255
Short Text numbers that do not require
characters.
calculating (e.g. phone
numbers).
Lengthy text or combinations Up to 63, 999
Long Text
of text and numbers. characters.
1, 2, 4, or 8
Numeric data used in bytes (16 bytes
Number
mathematical calculations. if set to
Replication ID).
Date and time values for the
Date/Time 8 bytes
years 100 through 9999.
Currency values and numeric
Currency data used in mathematical 8 bytes
calculations involving data
with one to four decimal
places.
A unique sequential
(incremented by 1) number
4 bytes (16
or random number assigned
AutoNumber bytes if set to
by Microsoft Access
Replication ID).
whenever a new record is
added to a table.
Yes and No values and fields
that contain only one of two
Yes/No 1 bit.
values (Yes/No, True/False,
or On/Off).
Here are some of the other more specialized data types, you
can choose from in Access.
Data
Description Size
Types
Files, such as digital
photos. Multiple files can
be attached per record.
Attachment Up to about 2 GB.
This data type is not
available in earlier
versions of Access.
OLE OLE objects can store Up to about 2 GB.
objects pictures, audio, video, or
other BLOBs (Binary
Large Objects)
Up to 8,192 (each
Text or combinations of
part of a Hyperlink
text and numbers stored as
Hyperlink data type can
text and used as a
contain up to 2048
hyperlink address.
characters).
The Lookup Wizard entry
in the Data Type column in
the Design view is not
actually a data type. When
you choose this entry, a
wizard starts to help you
define either a simple or
complex lookup field.
Dependent on the
Lookup
data type of the
Wizard A simple lookup field uses
lookup field.
the contents of another
table or a value list to
validate the contents of a
single value per row. A
complex lookup field
allows you to store
multiple values of the same
data type in each row.
You can create an
You can create an
expression that uses
expression that uses data
data from one or
from one or more fields.
Calculated more fields. You
You can designate
can designate
different result data types
different result data
from the expression.
types from the
expression.
These are all the different data types that you can choose
from when creating fields in a Microsoft Access table.
Let us try and create the first table that will store the basic
contact information concerning the employees as shown in
the following table −
Once all the fields are added, click the Save icon.
You will now see the Save As dialog box, where you can
enter a table name for the table.
Enter the name of your table in the Table Name field. Here
the tbl prefix stands for table. Let us click Ok and you will
see your table in the navigation pane.
TABLE DESIGN VIEW
As we have already created one table using Datasheet
View. We will now create another table using the Table
Design View. We will be creating the following fields in
this table. These tables will store some of the information
for various book projects.
In the tables group, click on Table and you can see this
looks completely different from the Datasheet View. In this
view, you can see the field name and data type side by
side.
We now need to make ProjectID a primary key for this
table, so let us select ProjectID and click on Primary
Key option in the ribbon.
You can now see a little key icon that will show up next to
that field. This shows that the field is part of the table’s
primary key.
Click Ok and you can now see what this table looks like in
the Datasheet View.
Let us click the datasheet view button on the top left corner
of the ribbon.
Let us add some data into your tables by opening the Access
database we have created.
Select the Views → Datasheet View option in the ribbon
and add some data as shown in the following screenshot.
You can now see that inserting a new data and updating the
existing data is very simple in Datasheet View as working in
spreadsheet. But if you want to delete any data you need to
select the entire row first as shown in the following
screenshot.
Click Yes and you will see that the selected record is deleted
now.
Ms Access - Query Data
A query is a request for data results, and for action on data.
You can use a query to answer a simple question, to perform
calculations, to combine data from different tables, or even
to add, change, or delete table data.
EXAMPLE
Let’s look at a simple example in which we will use criteria
in a query. First open your Access database and then go to
the Create tab and click on Query Design.
In the Tables tab on Show Table dialog, double-click on
the tblEmployees table and then close the dialog box.
Let us now add some field to the query grid such as
EmployeeID, FirstName, LastName, JobTitle and Email as
shown in the following screenshot.
Let us now run your query and you will see only these fields
as query result.
If you want to see only those whose JobTitle are Marketing
Coordinator then you will need to add the criteria for that.
Let’s go to the Query Design again and in Criteria row of
JobTitle enter Marketing Coordinator.
Let us now run your query again and you will see that only
Job title of Marketing Coordinators are retrieved.
If you want to add criteria for multiple fields, just add the
criteria in multiple fields. Let us say we want to retrieve data
only for “Marketing Coordinator” and “Accounting
Assistant”; we can specify the OR row operator as shown in
the following screenshot −
Let us now run your query again and you will see the
following results.
Select the table name from the drop-down list and click Ok.
In the Query grid, you can see that in the Append To row
all the field are selected by default except Address1. This
because that Address1 field is not available in
the TempEmployee table. So, we need to select the field
from the drop-down list.
Let us look into the Address field.
Let us now run your query and you will see the following
confirmation message.
Click Yes and go to Datasheet View and you will see the
first record — FirstName is updated to “Max” now.
Click Yes and go to your Datasheet View and you will see
that the specified employee record is deleted now.
CREATE A MAKE TABLE QUERY
You can use a make-table query to create a new table from
data that is stored in other tables. Let us go to the Create
tab again and click Query Design.
In the Tables tab, on the Show Table dialog box, double-
click the tblEmployees table and then close the dialog box.
Select all those fields which you want to copy to another
table.
Click Yes and you will see a new table created in the
navigation pane.
Ms Access - Parameter
Queries
The best part about queries is that you can save and run the
same query again and again, but when you run the same
query again and again by only changing the criteria then you
might consider the query to accept parameters.
EXAMPLE
Let us now take a look at a simple example by creating a
parameter query. Let us open your database and select
Query Design in the Create table tab.
Double-click on the tblProjects and close the Show dialog
box.
Let us now run your query and you will see the following
prompt.
Ms Access - Alternate
Criteria
Queries come in with many advantages. You can save and
run the same query again and again, and a lot of times you
want to add alternate criteria.
EXAMPLE
Let us look at a simple example of alternate criteria. Open
database and in the Create tab select Query Design.
Double-click on tblEmployee and close the Show Table
dialog box.
CustI Quantit
Name Address Cookie Price Total
D y
12 Main
St,
Ethel Chocolat $2.0 $10.0
1 Arlington 5
Smith e Chip 0 0
, VA
22201 S
1234 Oak
Tom Dr., Choc $2.0
2 3 $6.00
Wilber Pekin, IL Chip 0
61555
12 Main
Ethil St.,
Chocolat $2.0 $10.0
3 Smith Arlington 5
e Chip 0 0
y , VA
22201
Here, we have one table for Customers, the 2nd one is for
Orders and the 3rd one is for Cookies.
DEFINING RELATIONSHIPS
A relationship works by matching data in key columns
usually columns with the same name in both the tables. In
most cases, the relationship matches the primary key from
one table, which provides a unique identifier for each row,
with an entry in the foreign key in the other table. There are
three types of relationships between tables. The type of
relationship that is created depends on how the related
columns are defined.
ONE-TO-MANY RELATIONSHIPS
Ms Access - Create
Relationships
In this chapter, we will understand the need to create
relationships between related tables. One of the goals of
good database design is to remove data redundancy.
Let us now add another table into your database and name
it tblHRData using Table Design as shown in the following
screenshot.
Click on the Save icon as in the above screenshot.
Ms Access - One-To-One
Relationship
Let us now understand One-to-One Relationship in MS
Access. This relationship is used to relate one record from
one table to one and only one record in another table.
Ms Access - One-To-Many
Relationship
The vast majority of your relationships will more than likely
be this one to many relationships where one record from a
table has the potential to be related to many records in
another table.
• ANSI-89
• ANSI-92
EXAMPLE
Add the highlighted tables and close the Show Table dialog
box.
Add the fields in the query grid which you want to see as a
query result.
Now run your query and let us assume that you don’t know
the exact project name, but you know that the project name
contains the words “potion”. Click Ok.
The above step does not generate any result. That is because
Access is looking for an exact match in the project name
field. It is looking for that project which has the
word potion in its name.
When you run the query, users can use wildcards to replace
any number of characters.
Let us assume that you know that the word potion appears
somewhere in the title but you are not exactly sure where.
Let us say we want to find every project with the word “the”
in the title. Then, you need to just type the word
and Enter or click Ok.
With this query, it becomes easier to search for projects with
the word “the” in their names. The 2nd level of results may
also include the project names with the word “mother”
where “the” is part of the word.
Ms Access - Calculated
Expression
In MS Access, an expression is like a formula in Excel. This
consists of a number of elements that can be used alone or in
a combination to produce a result. Expressions can include
operators’, constants, functions and identifiers.
EXAMPLE
Let us try an example to understand this. We will be
retrieving some information from a variety of tables —
tblCustomers, tblOrders,
tblOrdersDetails and tblBooks and reviewing a variety of
fields.
Let us now run the query and you will see the following
results.
Let us try to run your query and you will see at end the
subtotal field.
Ms Access - Indexing
An index is a data structure, a special data structure
designed to improve the speed of data retrieval. If you often
search a table or sort its records by a particular field, you
can speed up these operations by creating an index for the
field. Microsoft Access uses indexes in a table as you use an
index in a book to find data.
You can adjust indexes by selecting any field. You can also
see how they are indexed in the field properties area below.
Any field that has No selected next to indexed, means there
is no index for that given field. You can change that by
clicking on the drop-down menu and choosing the other two
options — Yes (Duplicate OK) and Yes (No duplicates).
The last option Yes (No Duplicates) means that Access will
automatically prohibit duplicate values in that field. Let us
now create an index for our last name field.
Let us select LastName to index and say Yes (Duplicates
OK). As we save, Access will create that index. Another
area where you can view and adjust your indexes for a table
is the tables design area in the Show/Hide group.
If you click on this Indexes button that will bring up a
special view displaying all the indexes created for this table.
AGGREGATE QUERY
An aggregate query also known as a totals or summary
query is a sum, mass or group particulars. It can be a total or
gross amount or a group or subset of records. Aggregate
queries can perform a number of operations. Here's a simple
table listing some of the ways to total on a group of records.
Let us now run this query and you will see the following
results.
This is why book titles are repeating. Separate orders have
been placed for each of these books here and they were
ordered in different quantities. Let us assume we want to see
a summary of only that book title that has been listed only
once. And then the sum of the quantity listed beside it.
We will now group by book title and also sum our quantity
field.
CONCATENATION IN ACCESS
We learned the process of normalization, storing
information in separate fields. Sometimes you want to see or
view data together like combining the first name and last
name fields as a single field. You can display that
information together by creating a calculated field that
concatenates one or more strings. You can also add other
characters like a comma or period that you may want.
EXAMPLE
As you can see, the first name and the last name are
separated into two different fields.
Let us run the query and you will see a new calculated field.
In the above dialog box, you can see all kinds of special
queries. You can create a simple query wizard like how we
have been doing so far from the Design View. The second
one is the one we want — the crosstab query that displays
data in a compact spreadsheet like format. Now, select the
crosstab query and click Ok.
The first screen in the Wizard is going to prompt what table
or query contains the fields that you want for your Crosstab
Query results. Click on the Queries radio button and
select qryOrdersInformation — this is the one that we
created earlier which contain the subtotal, sales tax etc.
Click Next.
We will now look into the available fields from that query.
It will prompt you to enter the field values that you want as
row headings. Let us say we want a simple list of all of our
different book titles. Now select the book title fields and
send that over to your selected field area and click Next.
In the above dialog box, the question is what you want to
use as column headings and that really depends on what you
want to evaluate. Let us assume that you want to view
our sales by date, choose TransactionDate and click Next.
The question in the above dialog box is a specialized one
based on the field we previously selected since we chose a
date time column. It is asking if we want to group our date
time column information by a specific interval. Select the
year option and click Next.
The next question in the above dialog screen asks what
number do you want calculated for each column in the row
intersection. In this case, we can go by quantity of the books
sold by selecting quantity (QTY) and Sum from the
functions and click Next.
The very last screen of your wizard is going to ask what do
you want to name your query and further,
click Finish to View that query.
We now have book by book information and also
information on the total sales like when each one of those
sales occurred.
Ms Access - Joins
A database is a collection of tables of data that allow logical
relationships to each other. You use relationships to connect
tables by fields that they have in common. A table can be
part of any number of relationships, but each relationship
always has exactly two tables. In a query, a relationship is
represented by a Join.
WHAT IS JOIN
A join specifies how to combine records from two or more
tables in a database. Conceptually, a join is very similar to a
table relationship. In fact, joins are to queries what
relationships are to tables.
The following are the two basic types of joins that we will
be discussing in this chapter −
INNER JOIN
• You can choose the table that will display all rows.
• You can create a Left Outer Join which will include
all the rows from the first table.
• You can create a Right Outer Join that will include
all the rows from the second table.
Access will display the left table name and the right table
name in Join Properties dialog.
Those are the different types of joins you can create easily
from the Design View. Let us select the second option,
which is Left Outer Join, and click Ok.
When you look at the relationship line, you will see a little
arrow pointing towards ProjectID in tblTasks. When you
run this query, you will see the following results.
As you can see that it is showing us every single project
name, whether or not it has a related task. You will also see
a bunch of null fields. All of this will be blank because there
is no related information in tblTasks, where these fields
come from. Let us now go to the Design View again and
double-click on the relationship line.
In the Join Properties dialog box, select the third option
which is for the Right Outer Join and click Ok.
Now look at our relationship line. You will see that a little
arrow is now pointing towards ProjectID in tblProjects.
When you run this query you will see the following results.
SELF-JOINS
Self-join is another type of Join. A Self-join relates
matching fields from within the same table. For example,
look at the employee's table with a supervisor field, which
references the same kind of number stored in another field
within the same table — the employee ID.
If we wanted to know who Kaitlin Rasmussen's supervisor
is, we will have to take the number stored in that supervisor
field and look it up within the exact same table in that
employee ID field in order to know that Charity Hendricks
is the supervisor.
Ms Access - Duplicates
Query Wizard
In this tutorial, we have created a variety of select queries,
mainly from the Design View. But in Access, we can make
use of some special query wizards to create a couple of
specific select queries. The first one is Find Duplicates
Query wizard. The Find Duplicates Query Wizard will
create a query that locates records with duplicate field
values in a single table or query.
EXAMPLE
In a customer's table, you can have the same customer
accidentally added twice. In such cases, the customer will
have the same address, but different customer IDs, which
can create problems with reporting. In this situation, you can
make use of the duplicates query wizard to quickly locate
possible duplicate entries.
Let us now open our Access database which
contains tblAuthers table and go the Create tab and, in the
queries group, select query wizard.
The very first screen of the find duplicates query wizard will
ask what table or what query you want to search for possible
duplicates. Let us say we want to check our author's table to
make sure that the same author hasn't accidentally been
entered twice. So, select tblAuthors and click Next.
• The second screen in the wizard will ask what fields
might contain duplicate information.
• Typically, you will not be using your primary key
field, because, again, when you designate a field in
Access as a primary key, Access will not allow
duplicates to be entered.
• We will look at any other field or a combination of
fields.
We can search by the last name or the first name and the last
name, or you can search by their street address, or to be
more specific with their telephone number or birthday.
Let us now search by the first name, the last name, and
birthday and click Next.
The following screen in this wizard will ask for the fields we
want to be displayed in our query. For this, hit the double
arrow, all of the fields will move over to the additional
query fields area, and will be added to our query results.
If you'd like to see how that wizard has created this query,
go into the Design View and see what all has been added to
this query.
As you can see in the above screenshot, we have our fields
and some specific criteria underneath the first name field.
Ms Access - Unmatched
Query Wizard
In Access, there is another very useful wizard and that
is Find Unmatched Query Wizard. The Find Unmatched
Query Wizard creates a query that finds records or rows in
one table that have no related records in another table.
There are many other possible uses for this kind of query as
well.
The last screen will allow you to choose a name for your
query and click Finish.
Here we have one customer listed as that customer who has
not placed an order with us yet.
You can also see how that query was created. For this, you
need to go back to the Design View.
This wizard has created an Outer Join between tblCustomer
and tblOrders and the Is Null criteria is added to the CustID
from tblORders. This is to exclude certain records. In this
case, it is the customers who have placed orders, or who
have related information in tblOrders.
• Bound forms
• Unbound forms
BOUND FORMS
Let us now understand what Bound Forms are −
UNBOUND FORMS
Let us look into Unbound Forms −
This is the most popular one and this is where the records
are displayed — one record at a time.
SPLIT FORM
CREATING FORMS
There are a few methods you can use to create forms in
Access. For this, open your Database and go to the Create
tab. In the Forms group, in the upper right-hand corner you
will see the Form Wizard button.
Click on that button to launch the Form Wizard.
On this first screen in the wizard, you can select fields that
you want to display on your form, and you can choose from
fields from more than one table or a query.
Once you have given your form a title, you can open the
form to see what that form looks like, or you can begin
entering information into your table. Or you can choose the
option to modify the form's design. Let us choose the first
option to open the form to view or enter information and
click Finish.
Now, take a look at the following screenshot. This is what
your form looks like. This is a single item form, meaning
one record is displayed at a time and further down you can
see the navigation buttons, which is telling us that this is
displaying the record 1 of 9. If you click on that button then,
it will move to the next record.
If you want to jump to the very last record in that form or
that table, you can use the button right beside that right
arrow, the arrow with a line after it, that's the last record
button. If you want to add new employee information, go to
the end of this records and then after 9 records you will see a
blank form where you can begin entering out the new
employee's information.
This is one example of how you can create a form using the
Form Wizard. Let us now close this form and go to the
Create tab. Now we will create a slightly more complicated
form using Wizard. Click the Form Wizard and this time,
we will choose fields from a couple of different tables.
To create this type of form, you will need to select the object
in navigation pane first. Let us select tblEmployees here.
Proceed by clicking on More Forms and Multiple Items.
CONTROLS
It is merely a generic term used to describe any object on a
form or report that displays data, performs actions or items
used for decorations such as a line. In other words, a control
is just about anything that is placed on a form or report.
When you take your mouse and click on any one of these
controls, you will notice that Access will highlight a given
area of that form and all controls within that area are shaded
a light orange whereas the actual control that you select will
be shaded darker than the previous one or have a darker
orange border around where you click.
Here you can resize your controls as you want by clicking
and dragging your mouse to resize the height or width or
both of that one control.
On this particular form, when you resize any single control,
you also change the size of the rest of your controls on your
form, this is because of how these controls are grouped. Let
us now adjust all the fields the way you want by using the
click and drag function of the mouse.
THEMES
In Access, there are some basic ways to format your forms
by using built-in themes, colors, and font styles, customizing
fill colors and shading alternate rows. Let us now
open frmEmployees.
The forms that Access creates are plain and simple. They
have a blue bar on the top and a white background.
If you want to see how else you can stylize these forms, you
can go to the Design View or Layout View and explore
some of the options you have on the Design tab in the
Themes area.
If you click on the Themes' drop-down gallery, you have
many pre-created themes to try out from. Hovering your
mouse over any one of them will give you a preview of
changing things like colors and font sizes and the actual font
used. To apply a particular style, simply click your mouse
on it and you can see what that looks like.
If you like the theme but you want to change the colors, you
can adjust the colors by going back to the Themes group on
the Design tab and choosing the color you like. You can also
create custom colors to match your company's colors.
Similarly, you also have a series of font styles to choose
from. You can choose one from the many that come prebuilt
with the Office Suite or you can customize those fonts,
choosing a specific heading font, a body font and even
creating a custom name for that font group and saving.
Let us go back to frmEmployees. In this form, you will see
that every alternate row is shaded light gray.
The formatting option is referred to as Alternate Row
Color and if you want to adjust that in a multiple form, go
to the Design View.
Select that detail section and then go to the Format tab and
in background group you should see an option for Alternate
Row Color. You can change the colors for alternate rows.
To see what that looks like, simply go to the Form View or
the Layout View.
If you don't want any shading at all, you can choose No
Color as your Alternate Row Color and that is more the
traditional look from earlier versions of Access.
Ms Access - Navigation
Form
Access includes a Navigation Control that makes it easy to
switch between various forms and reports in your database.
A navigation form is simply a form that contains a
Navigation Control. Navigation forms are a great addition to
any desktop database.
EXAMPLE
Let us now take a simple example in which we will create
the navigation form. For this, go to the Create tab; in the
Forms group, you will see this navigation drop-down menu.
Now, you will see that your other project buttons have
disappeared from the left and that is because they are
attached to Project tab. All the buttons you view on the left
are linked to whatever you have selected up the top. Now
with the Employee tab selected, let us drag employees-
related information to the left.
Now we have project information on one tab, employee
information on the other. Similarly, you can add more tabs
as per your requirements. As you can see that the name of
the tabs is not appropriate, so let us start renaming some of
these tabs to make them more user-friendly. The easiest way
is to double-click on any tab or any button on the left and
rename it as shown in the following screenshot.
Ms Access - Combo BOx
When you enter data in any form, it can be quicker and
easier to select a value from a list than to remember a value
to type. A list of choices also helps ensure that the value
entered in a field is appropriate. A list control can connect to
existing data, or it can display fixed values that you enter
when you create the control. In this chapter, we will cover
how to create a combo box in Access.
COMBO BOX
A combo box is an object or control which contains a drop-
down list of values that the user can select from.
EXAMPLE
To the left, you will see the Stacked option. Click this
button.
You can now see the fields are aligned.
Select the Query Design from the Create tab and add
the tblEmployees table.
Select the field you want to see as query result and then run
your query.
You can now see all the employee information as query
result. You have selected certain fields in the Query Grid; at
the same time, MS Access has also created an SQL Query
with the results obtained from your Query Grid.
Ms Access - Formatting
One especially useful formatting tool in Access is the ability
to apply Conditional Formatting to highlight specific data.
Let us take a simple example of conditional formatting.
EXAMPLE
In this example, we will be using a
form fSubCurrentProjects in our database.
We have a list of all of the projects in this database and we
have also got a couple of new fields like the On Time
Status and the Number of Late Tasks. This form is created
from another query.
In this query, we have a join between a table and a query
that will display the count of due dates or how many
projects have tasks that are overdue. We also have a
calculated field here that uses the IF function to determine
whether or not the count of the due date is greater than zero.
It will then display the words Late if the project is late
or On Time if that specific project does not have any
overdue tasks.
EXAMPLE 1
In this example, we will be using the above form to
understand how you can use Conditional Formatting to
highlight specific pieces of information. We will now
highlight every single project that is currently running late.
To apply Conditional Formatting to one field or more than
one field, we will need to switch over to the Layout view.
EXAMPLE 2
Let us take another example. Here, we will make the title or
the name of the project red and bold, italic and underline.
Select the project name control on your form.
We will now go back to our Format tab and click on
Conditional Formatting and create a new rule for that
specific control as shown in the above screenshot.
Click on the New Rule button to create a new rule and then
click Ok as in the above screenshot.
In the New Formatting Rule, we will now select a rule type
“Compare to other records”. Let us further change the Bar
color to red. We want our shortest bar to represent the
lowest value and the longest bar to represent the highest
value. Let us now click Ok and then, click Apply and Ok
again.
BOUND CONTROLS
Let us now understand what Bound Controls are −
UNBOUND CONTROLS
Let us now understand what Unbound Controls are −
CONTROL TYPES
You can create different types of controls in Access. Here,
we will discuss a few common ones such as Text box,
Label, Button Tab Controls etc.
TEXT BOX
• Typically, anything that is in a text box will be
bound, but not always.
• You can use these controls to interact with the data
stored in your database, but you can also have
unbound text boxes.
• Calculated controls will perform some kind of
calculation based on an expression that you write
and that data is not stored anywhere in your
database.
• It is calculated on the fly and live just on that one
form.
LABELS
BUTTON
TAB CONTROLS
HYPERLINK
EXAMPLE
Let us now select all the fields from tblEmployees and drag
to query grid, and similarly add all the fields from
tblHRData.
You can now see the query as its Record Source. We have
now bound this form to an object in our database, in this
case qryEmployeesData. We can now start by adding some
controls to this form and to add any one of the controls, go
to the Design tab and view your options from the controls
group.
From the Controls menu, you will see that the Use Control
Wizard is highlighted as in the above screenshot. This little
button has that highlighted box around it by default. This
means that the control wizards are turned on. This is like a
toggle switch. When you click on the toggle switch the
wizards turn off. Clicking it again will turn the wizards on.
Let us now click on the Label and drag this label and enter
Employee Information and then go to the Format tab to
format it as in the following screenshot.
You can choose to apply a bold style or change the font size
of text inside that label etc. This control appears inside the
detail section of your form. It makes more sense to position
this label inside the form header section, which is not visible
yet.
Right click anywhere in the background of that form and
choose Form Header as in the above screenshot.
Move this control into the Form Header area. Let us now
create some other controls from the Design tab. At this
point, Let us say, we want to distribute all our fields into
two different tabs.
From the control menu, you can see the Tab Control which
will create tabs on your form. Click on the tab control and
draw it on your form in the detail section as in the above
screenshot.
It will create two tabs — page 2 and page 3 as in the above
screenshot.
EXAMPLE
Let us now change the Title of the report and give it another
name.
Click on the save icon to save your report.
Enter a name for your report and click Ok. If you want to
view what this report will actually look like, in Print
Preview, you can go back to the View button and click on
Print Preview to see what this report would look like when
printed either on paper or as a PDF.
Using the tools on the lower right-hand corner, you can
zoom in or zoom out. You also have some buttons on the
Print Preview tab that appear automatically when you switch
to Print Preview. In the zoom section, you've got a view for
one page, two pages; or if you have a longer report, you can
view four pages at once, eight pages or twelve pages. You
can also adjust simple things such as the size of the paper
that you are using to print, the margins for your report, the
orientation, the number of columns, page set up, etc. And
that is how you can create a very quick simple report using
the Report button on the Create tab.
Ms Access - Formatting
Reports
In this chapter, we will learn how to format reports. You
will find that there are a lot of similarities between
formatting reports and formatting forms but there are a few
tools and tricks that are specific to reports. Let us now look
into the concept of report sections and grouping.
Right click anywhere on that report and you will see Page
Header/Footer and Report Header/Footer. This particular
report does not have that Report Header/Footer visible. Let
us select that option and go back to the Report View.
You can see it just adds a little colored area at the very top
of the report. In the Design View, expand that area by
hovering the mouse right at the top of that page header
divider, clicking and dragging down. This will add more
area to the report header.
In the Report View, you will now see more area at the very
top of the report as in the following screenshot.
If you want to make the project name bigger, then drag the
line below and change the font size to 20 in the Format Tab.
You can increase the width of the control to cover the entire
width of the page.
To remove the border around the control, click on the Shape
Outline in the Format tab as in the following screenshot.
Let us now bring the data from the Page Header section to
the ProjectName header section using Ctrl+X and Ctrl+V.
Let us now go back to the Report View. You will now see
that the labels appear directly above the controls that they
describe.
If you notice, you will see that there is no space between the
tasks and the next project name. There should be additional
space in between. For that, we need to add ProjectName
Footer.
In the Group, Sort and Total area click on the More button
next to the project name.
You will now find all the options for how to group and sort
by project name as in the following screenshot.
Here, we have a property called Without a Footer Section.
Let us change that option by clicking on that little arrow
next to the words Without a Footer Section.
Change it to With a Footer Section.
Ms Access - Built-In
Functions
In this chapter, we will be working with Built-in Functions.
In Access, there are close to a hundred built-in functions and
it is almost impossible to cover every single one of them. In
this chapter, we will cover the basic structure, syntax, and
use some of the more popular functions, and also the
pitfalls, so that you can go exploring some of the other
functions on your own.
FUNCTIONS
A function is a VBA procedure that performs a task, or
calculation, and returns a result. Functions can generally be
used in queries, but there are other places that you can use
functions.
Let us now open your database and create a new query using
query design and add tblProjects and tblTasks.
Add ProjectName from tblProjects and TaskTitle, StartDate
and DueDate from tblTasks and run your query.
You can now see all the different tasks from all projects. If
you want to view the project tasks that are in progress as on
today’s date, then we have to specify a criterion using
a Date() Function to look at projects that start on or after
today's date.
When we run this query, all the tasks will occur either on
today's date or in the future as in the following screenshot.
This was an example of how you can use the Date() function
as query criteria.
If we want to view the tasks that started this week, that have
not yet completed or should complete today, let us go back
to the Design View.
DATEDIFF() FUNCTION
The DateDiff() Function is another very popular date/time
function. The DateDiff Function returns a Variant (long),
specifying the number of time intervals between two
specified dates. In other words, it calculates the difference
between two dates, and you get to pick the interval by which
the function calculates that difference.
Now, run your query and you will see the new field which
shows the age of each author.
FORMAT() FUNCTION
The Format() Function returns a string, containing an
expression formatted according to instructions contained in
a format expression. Here is the list of user-defined formats
which can be used in Format() function.ss
Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second
Let us now go back to your query and add more fields in the
same using the Format() function.
IIF() FUNCTION
The IIf() Function is an abbreviation for “Immediate If” and
this function evaluates an expression as either true or false
and returns a value for each. It has up to three function
arguments, all of which are required.
EXAMPLE
Let us take a simple example. We will create a new query
using query design and add tblAuthors table and then add
the following fields.
Let us now run your query and you will see the results as in
the following screenshot.
Do you want to learn the really advanced content that we
couldn’t include in this eBook?
1. Excel-based Production Scheduling System CLICK HERE
2. Dose For Excel Add-in CLICK HERE
3. Aplica Excel Contable (view mobile) CLICK HERE
Ms Access - Macros
In this chapter, we will cover the basics of Macros in
Access. A Macro is a tool that allows you to automate tasks
and add functionality to your forms, reports, and controls.
CREATING A MACRO
Let us start be creating a very simple Macro that opens a
form when a command button is clicked. For this, we need
to open your database and frmEmployeeData form in which
we have created two tabs.
In this form, we can add a button allowing users to open up
all of the job information.
You will now see a View Jobs button on your form. Let us
click on it.
Now you have a form open, but you will not be viewing any
information. Let us go back to the frmEmployeeData form
Design view. Make sure that the command button is selected
and click on the Event tab on the Property Sheet.
Upon clicking, you will see an embedded Macro created by
the Wizard. If you now want to modify this Macro, click on
the … button to open up the Macro generated by the
Wizard.
This is the Macro Designer and on the right you will see the
Action Catalog. This is where all of your actions will live in
folders. You have the Data Entry options, Data
Import/Export and so on, and on the left in the main area
you have another Macro. It only contains one action, and
clicking on that one action you can view other properties for
that specific action.
You will see the form name and you can hit that drop-down
arrow to view the forms available in your database. You can
change how that form is viewed, you can have it open to
Form view, Design view, Print Preview at your choice. You
can apply a filter name or a Where condition. Here we want
to change the Data Mode because frmJobs is set to the Add
Mode which only allows the addition of new records. We
can override this here in this Macro by changing it to the
Edit Mode.
Now save your Macro, and then close the Macro Designer
and go back to the Form View.
In the import & Link group, you can see the different kind
of options available for data import in Access. Following are
the most commonly used data import formats.
EXAMPLE
Here you will see the preview of your data. Now, click
Next.
In the Preview, you can now see that the first row contains
the column headings. Let us now check the check box and
click Next.
You will now see a dialog box where you can set the data
type for each column/field. If you don’t want to import any
field, just check the check box which says do not import
field. Once you are done with the FirstName field, just click
on the MiddleInitial field.
Let us now go through all the fields and then, click Next.
Here are the different options for primary key. Let us select
the first option and click Next.
In the last dialog box, you can enter the table name of your
choice and click Finish.
If you want to save all these steps, then check the checkbox
and close the dialog box.
EXAMPLE
Let us look at a simple example of data export from Access.
Open your database where you want to export the data from.
In the Navigation Pane, select the object that you want to
export the data from.
You can export the data from table, query, form, and report
objects etc. Let us select the qryAllProjects and then, go to
the External Data tab.
On the External Data tab, click on the type of data that you
want to export to. For example, to export data in a format
that can be opened by Microsoft Excel, click Excel.
Access starts the Export wizard. In the wizard, you can set
the information such as the destination file name and format,
whether to include formatting and the layout, which records
to export. Once you are done with the required information,
click Ok.
On this screen of the Wizard, Access usually asks you if you
want to save the details of the export operation. If you think
you will need to perform the same operation on a recurring
basis, select the Save export steps check box and close the
dialog box.
Thank you!