hands-on exercise

HANDS-ON EXERCISE
HOE1 Training
1 Table Design, Properties, Views, and Wizards
Assisting the bank auditor at Commonwealth Federal Bank as he investigates the mishandled funds will be a great opportunity for
you to showcase your Access skills. Be sure to check your work each step of the way since your work will come under substantial
scrutiny. Do a good job with this Access project and more opportunities might come your way, along with a promotion.
Skills covered: Create a New Database • Create a Table by Entering Data • Change the Primary Key, Modify Field Properties,
and Delete a Field • Modify Table Fields in Design View • Create a New Field in Design View • Switch Between the Table Design
and the Table Datasheet Views
STEP1
CREATE A NEW DATABASE
To start a new Access database project, you first need to create a new database. Use the Access
interface to create a new file for the mishandled funds database. Refer to Figure 2.8 as you complete
Step 1.
Home
Create
External Data
- -i
o
Database To
Available Templates
*•
f Click Blank database
•*
ffl
Home
• Open
3tJ Northwmd.actdt.
3Q a02m2hotel.accdb
iS] a02mlproperty.a«db
a
Blank
database
;
;
Blank web
database
Recent
templates
Office.com Templates
Sample
templates
My templates
|Search Offict.com for template
•»
fflj a02mlproperty_Las...
Browse to select a folder
Assets
Contacts
Issues &
Tasks
Non-profit
Projects
File Name
Sample
f Type the file name JHelp
-Oatabasel.accdb
C:\Users\keith\Documents\.
"I tf
Start Microsoft Access.
J Options
Click Create to create the ]_
new database
FIGURE 2.8 Creating a New
Microsoft Office Access
Database >
You will see the Backstage view with New selected by default.
b. Click Blank database in the Available Templates section of the Backstage view.
C. Type a02hlbank_LastnameFirstname into the File Name box.
d. Click Browse—the yellow folder icon—to find the folder location designated by your
instructor, and then click OK.
e. Click Create to create the new database.
Access will create the new database named a02hlbank_LastnameFirstname, and a new table
will automatically appear in Datasheet view.
CHAPTER 2 • Relational Databases and Queries
Cl
TROUBLESHOOTING: If you have a problem finding your file, use the Windows search tool to
locate the file.
STEP 2
CREATE A TABLE BY ENTERING DATA
Create a new Branch table and enter the branch data as instructed. Only branches with suspicious
data will be added. Refer to Figure 2.9 as you complete Step 2.
| Branch
Save the table as Branch J—
»
ID
(
Type the data directly |_
into the datasheet J
1 BIO
j B?n
—H
• 2 .9 Enter Data into
ich Table in Datasheet
4 840
Esposito
Amoako
Singh
5 B50
YourlastName
3 B30
_
Field2
Mast
»j
Field3
•* Click to Add
-
Uptown
Eastern
Western
Southern
Campus
|(New)
*
View
a. Type BIO in the second column, and then click Click to Add.
The column heading becomes Fieldl and Click to Add now appears as the third column.
b. Type Mast in the third column, press Tab, and then type Uptown in the fourth column.
You can advance to the next field by pressing Tab or move to the previous field by pressing
Shift+Tab.
C. Press Tab three times. Type B20, press Tab, type Esposito, press Tab, and then type Eastern.
d. Enter the additional data for the new table as shown in Figure 2.9. Replace YourLastName
with your last name.
e. Click Save on the Quick Access Toolbar. Type Branch in the Save As dialog box, and then
click OK.
Entering data provides an easy way to create the table initially. You can now modify the
table in Design view as described in the next several steps.
STEP 3
CHANGE THE PRIMARY KEY, MODIFY FIELD PROPERTIES, AND DELETE A FIELD
It is common to modify tables even after data has been entered; however, pay attention to the
messages from Access after you make a design change. In this example, you will be modifying the
Branch table field names to match the auditor's requirements. Refer to Figure 2.10 as you complete
Step 3.
Hands-On Exercises • Access 2010
_J Branch
[ BranchlD is the
primary key
Field Name
Description
Rename field names
in Design view
Design view for the 1
Branch table
Change Field Size i_
property here
[
Change the Indexed
property here
FIGURE 2.10 Branch Table
in Design View >•
Validation Rule
Validation Text
Required
Allow Zero Length
Indexed
Unicode Co
ession
[ME Mode
IME Sentence Mode
ode
Smart Tags
A field name can be up to 64 characters long,
including spaces. Press Fl for help on field
names,
Yes (No Duplicates)
ires
No Control
None
J»
a. Click View in the Views group to switch to the Design view of the Branch table.
The fields are named ID, Field 1, Field2, and Fields, because they are the default names
given to the fields when you create the table in Datasheet view. These field names are not
descriptive of the data, so you need to change Field 1, Field2, and Fields to BranchlD,
Manager, and Location, respectively. You will also delete the ID field.
b. Click the ID field to select it. Click Delete Rows in the Tools group. Click Yes to both
warning messages.
Access responds with a warning that you are about to permanently delete a field and a
second warning that the field is the primary key. You delete the field since you will set a
different field as the primary key.
C. Double-click the Fieldl field name to select it, if necessary, and then type BranchlD.
Replace Field2 with Manager and Field3 with Location.
d. Click the BranchlD field.
The cell field name now has an orange border as shown in Figure 2.10.
6. Click Primary Key in the Tools group.
You set BranchlD as the primary key. The Indexed property in the Field Properties section
at the bottom of the design window displays Yes (No Duplicates).
f. Click Save to save the table.
You can right-click a row selector to display a shortcut menu to copy a field, set the primary
key, and insert or delete rows. Use the shortcut menu to make these specific changes to the
design of a table.
CHAPTER 2 • Relational Databases and Queries
STEP 4
MODIFY TABLE FIELDS IN DESIGN VIEW
You need to modify the table design further to comply with the bank auditor's specifications.
Be aware of messages from Access that indicate you may lose data. Refer to Figure 2.11 as you
complete Step 4.
Field Name
Data Type
f> BranchID
Text
Manager
Text
Location
!*•
Text
j
[ BranchID is selected
Description
I
| Indexed property is set J
I
to Yes (No Duplicates) \ Add a Caption j
-
Field Size has been
Field Properties
changed to 5
i
FIGURE 2.11 Changes to the
Field Properties of the Branch
Table in Design View >
i
General Lookup
1
Field Si:*
Format
Input Mask
Caption
Default Value
Validation Rule
Validation Text
Required
Allow Zero Length
Indexed
Unicode Compression
IME Mode
IME Sentence Mode
Smart Tags
»
-Q
Bran hID
No
Ves
Ves (No Dup
Yes
No Control
None
An index speeds up searches and sorting on
the field, but may slow updates. Selecting
"Yes - No Duplicates' prohibits duplicate
values in the field. Press Fl for help on
indexed fields.
^^T
Q
*
a. Click the BranchID field name in the top section of the design window; modify the
BranchID field properties in the bottom of the design window:
• Click in the Field Size property, and then change 255 to 5.
• Click in the Caption property, and then type Branch ID. Make sure branch and ID have
a space between them.
A caption provides a more descriptive field name. It will appear as the column heading in
Datasheet view.
• Check the Indexed property; confirm it is Yes (No Duplicates).
b. Click the Manager field name at the top of the window; modify the following field
properties:
• Change the Field Size property from 255 to 30.
• Click in the Caption property, and then type Manager's Name.
C. Click the Location field name, and then modify the following field properties:
• Change the Field Size property from 255 to 30.
• Click in the Caption property, and then type Branch Location.
STEPS
CREATE A NEW FIELD IN DESIGN VIEW
You notify the auditor that a date field is missing in your new table. Modify the table and add the new
field. The data can be entered at a later time. Refer to Figure 2.12 as you complete Step 5.
Hands-On Exercises • Access 2O1O
'
_J Branch
( Date/Time data type
Field Name
,
( New field added
Data Type
BranchID
Text
Manager
Location
Text
Text
Date/Time
StartDate
Description
This date is the date the manager started working at this location.
f Description was added
Microsoft Access
Some data may be lost.
The setting for the FieldSize property of one or more fields has been changed to a shorter size. If data is lost,
validation rules may be violated as a result.
Do you want to continue anyway?
f Message indicates the
field size was reduced
Field Properties
FIGURE 2.12 Adding a New
Field to the Branch Table >
a. Click in the first blank row below the Location field name, and then type StartDate.
You added a new field to the table.
b. Press Tab to move to the Data Type column. Click the Data Type arrow, and then select
Date/Time.
You also can type the first letter of the data type such as d for Date/Time, t for Text, or n for
number. To use the keyboard shortcut, click on the field name, and then press Tab to advance
to the Data Type column. Next, type the first letter of the data type.
c. Press Tab to move to the Description column, and then type This is the date the manager
started working at this location.
d. Click in the Format property, click the arrow, and then select Short Date from the list of
date formats.
e. Click in the Caption property, and then type Manager's Start Date.
f.
Click Save on the Quick Access Toolbar to save the changes you made to the
a02hlbank_LastnameFirstname database.
A warning dialog box opens to indicate that "Some data may be lost" since the size of the
BranchID, Manager, and Location field properties were shortened. It asks if you want to
continue anyway. Always read the Access warnings! In this case, you can click Yes to continue.
You changed the size of the BranchID field from 255 to 5 in Step 4a.
g. Click Yes in the warning box.
CHAPTER 2 • Relational Databases and Queries
STEP 6
SWITCH BETWEEN THE TABLE DESIGN AND THE TABLE DATASHEET VIEWS
As you work with the auditor, you will need to modify tables in the bank database from time to time.
To modify the table, you will need to switch between Design view and Datasheet view. Refer to
Figure 2.13 as you complete Step 6.
Right-click the Branch tab
and use the shortcut menu
to switch views
1 Branch
Branch ID
BIO
B20
( Start dates were entered
for each manager
Pencil indicates the last
I record has not been saved
B30
B40
~.$ B50
^ Manager's Nairn - Branch Local - Manager's Sta - Click to Add Mast
Esposito
Amoako
Singh
YourLastName
Uptown
Eastern
Western
Southern
Campus
12/3/2007
6/18/2008
3/13/2006
9/15/2009
10/11/2011 H
#
FIGURE 2.13 Start Dates
Added to the Branch Table >•
a. Right-click the Branch tab shown in Figure 2.13, and then select Datasheet View from the
shortcut menu. (To return to the Design view, right-click the tab again, and then select
Design View.)
b. Click inside the Manager's Start Date in the first record, and then click the Calendar. Use
the navigation arrows to find and select December 3, 2007 from the calendar.
You can also enter the dates by typing them directly into the StartDate field.
c. Type directly in each field the Start Date for the rest of the managers as shown in
Figure 2.13.
d. Click the Close button at the top-right corner of the datasheet, below the Ribbon.
X
v
N
TROUBLESHOOTING: If you accidentally click the Close button on top of the Ribbon, you will
exit out of Access completely. To start again, launch Access, click the File tab, click Recent, and
then select the first database from the recent documents list.
/
6. Double-click the Branch table in the Navigation Pane to open the table. Check the start
dates.
The start dates are still there even though you did not save your work in the previous step.
Access saves the data to the hard drive as soon as you move off the current record (or close
an object).
f.
Click the File tab, click Print, and then click Print Preview.
Occasionally, users will print an Access table. However, database developers usually create
reports to print table data.
g. Click Close Print Preview. Close the Branch table.
h. Click the File tab, and then click Compact & Repair Database (the top button).
i.
Click the File tab, click Save & Publish, and then double-click Back Up Database in the right
column. Accept a02hlbank_LastnameFirstname_date as the file name, and then click Save.
You created a backup of the database. The original database, a02hlbank_LastnameFirstname,
remains open.
j.
Keep the database onscreen if you plan to continue with Hands-On Exercise 2. If not, close
the database and exit Access.
Hands-On Exercises • Access 2O1O
*