Office2016VideoProject39 BuildAccessDatabase
Office2016VideoProject39 BuildAccessDatabase
This handout lists the steps for building an Access Database for a small kiosk business in a mall. The name of the
business is Wooden Crafts. Wooden Crafts sell wooden toys. Wooden Crafts has asked you to design a database that
stores product data and supplier data that will produce reports such as product list, supplier list and inventory value.
Click Blank
database to
create a new
database.
ii. In the next window, click on the Browse button to save the database to the correct folder for Access:
Page 1 of 25
iii. In the File Name textbox, type the name of the database: “WoodenCraftsDatabase”. Then click the
Create button to create the new database file.
File Name
Page 2 of 25
i. Here is a view of the new database and the new Products Table. Use the Close Button for the Products
Table. We will come back and do extensive work on this table later.
ii. Now we need to import the Supplier Table from the Excel File named “V39-SupplierDataFromExcel.xlsx”
(you download file from our web page).
iii. On the External Data Tab, click the New Data Source dropdown, then click on Excel.
iv. “In the Get External Data – Excel Spreadsheet” dialog box:
1. Use the Browse button to navigate to the Excel file named “V39-SupplierDataFromExcel.xlsx”.
2. Make sure that the “Import the source data into a new table in the current database” dialog
button is selected.
3. Click OK.
Make sure that Use the Browse button
the “Import the to navigate to the Excel
source data into file named “V39-
a new table in SupplierDataFromExcel.x
the current lsx”
database” dialog
button is
selected
4.
Page 3 of 25
v. In the next window you can accept the default settings:
vi. In the next window, check the check box for “First Row Contains Column Headers”:
vii. In the next window, for the Supplier Code Field Name, select “Yes (No Duplicates)” in the Indexed
textbox dropdown:
Select
“Yes (No Duplicates)”
Page 4 of 25
viii. In the next window, select “Choose my own primary key” for the Supplier Code Field.
ix. In the next window, we can accept the table name “SupplierData”. Click Finish.
x. In the last window click the Close button (window not shown)
xi. Now we can see the imported SupplierData Table in the Navigation Pane.
Page 5 of 25
3. Add Data Types and Field Properties to each Field in the SupplierData Table
i. As we talked about last video Data Types and Field Properties allow us to add Data Validation to our
Fields so that “Bad Data” doesn’t get into our Field.
ii. Following are two tables that list the different Data Types and the different Codes for Input Masks:
Page 6 of 25
2. Code for Input Mask (like Number Formatting in Excel) for Field Properties:
Character Description
0 Digit (0 to 9, entry required, plus [+] and minus [?] signs not allowed).
9 Digit or space (entry not required, plus and minus signs not allowed).
Digit or space (entry not required; spaces are displayed as blanks while in Edit mode, but blanks
# are removed when data is saved; plus and minus signs allowed).
L Letter (A to Z, entry required).
? Letter (A to Z, entry optional).
A Letter or digit (entry required).
a Letter or digit (entry optional).
&; Any character or a space (entry required).
C Any character or a space (entry optional).
Decimal placeholder and thousand, date, and time separators. (The actual character used depends
.,:;-/ on the settings in the Regional Settings Properties dialog box in Windows Control Panel).
< Causes all characters to be converted to lowercase.
> Causes all characters to be converted to uppercase.
Causes the input mask to display from right to left, rather than from left to right. Characters typed
into the mask always fill it from left to right. You can include the exclamation point anywhere in
! the input mask.
** |Causes the character that follows to be displayed as the literal character (for example, \A is displayed as just A).
Page 7 of 25
iii. First, we want to open our Supplier Table in “Regular View” or Datasheet View. In the Navigation Pane,
double-click the Supplier Data Table. We can see we have four suppliers.
iv. Now we want to view the table in Design View so that we can add the correct Data Types and Field
Properties to each Field. To show the table in Design View click the View Button in the View group in the
Home Ribbon Tab.
Data Types
for each Field
Fields are
Field Properties for selected Field
listed
“Supplier Code”
vertically
Page 8 of 25
vi. For the Supplier Code Field our Data Type, Description and Field Properties are:
1. Data Type = Short Text
2. Description = “Primary Key - this will be the Foreign Key in the Products Table.”
3. Field Properties are:
i. Field Size = 2
ii. Input Mask = >LL (this means letters are always capital and two letters must be entered)
vii. The remaining Data Types, Descriptions and Field Properties are seen in the following pictures, one for
each Field:
viii. First Name:
Page 9 of 25
x. Address:
xi. City:
xii. State (State is a two capital letter abbreviation so we use input mask >LL ):
xiii. Zip Code (not a Number Data Type because we will never do math operations on this field):
Page 10 of 25
xiv. Telephone (not a Number Data Type because we will never do math operations on this field):
xv. The finished list of Fields, Data Types and Field Properties is seen below. Using Ctrl + S, Save the changes
you made to the SupplierData Table Object. Then Close the window.
Page 11 of 25
4. In Access create a Product Table and add Data Types and Field Properties
i. We already have an automatic table that was created when we created the database, and we named it
Products. Now we need to open it in Design View and add Field, Data Types and Field Properties. To
open it in Design View, right-click the Products table in the Navigation Pane and point to Design View,
like in this picture:
ii. Below is the Products Table shown in Design View. An automatic Primary Key was added with an
AutoNumber Data Type. We do not want this field in our table.
iii. To delete the field, right-click the Field Name and click on Delete Rows.
1.
iv. When the dialog box pops up, click Yes, like in this picture:
1.
Page 12 of 25
v. We now need to create our own Primary Key (Unique Identifier for each Product). For the first field in
the Products Table, our Data Type, Description and Field Properties are:
1. Field Name = Product ID
2. Data Type = Short Text
3. Description = “Product ID - Primary Key - Rule for PK = 2 Capital Letters AND 2 Numbers”
4. Field Properties are:
i. Field Size = 4
ii. Input Mask >LL00 (this means two letters and two numbers must be entered and
letters will be capitalized)
vi. To convert the field to a Primary Key, you can right-click the Field Name and click on the Key Icon:
Primary
Key Icon
viii. The remaining Data Types, Descriptions and Field Properties are seen on the next page. The Raw Data
for the Products Table is also seen on the next page.
Page 13 of 25
ix. You can use the below table to complete the Field Names, Data Types and Field Properties for the Products Table, however, for the last two
fields, Supplier Code and Wholesale Retail, you want to see instructions on the next few pages.
Page 14 of 25
5. Use Data Type Lookup Wizard to connect the Products table to the SupplierData table with a One-To-Many
Relationship between the two Supplier Code Fields. We will also use Lookup Wizard to create a Whole Sale
Retail Field.
x. Here are the instructions for creating the Supplier Code and Wholesale Retail fields:
xi. Supplier Code Field:
1. Type Field Name “Supplier Code”
2. Select the Data Type “Lookup Wizard”:
3. In the first dialog box, select “I want the lookup field to get the values from another table or
query”. Then click Next.
4. In the second dialog box, select the SupplierData Table. Then click Next.
Page 15 of 25
5. In the third dialog box from the Available Fields list on the left, select Supplier Code and then
click the Single Arrow Button to move the Field to the Selected Fields on the right.
6. After you click the Single Arrow Button to move the Field to the Selected Fields on the right, the
dialog box will look like the one below. Then click Next.
7. In the fourth dialog box, select Supplier Code from the Ascending textbox dropdown. Then click
Next.
i.
Page 16 of 25
8. In the fifth dialog box, click Next.
10. When the next dialog box asks you to save before relationship can be created, click Yes.
Page 17 of 25
11. The finished Supplier Code Field is show. Notice how it adopted the Field Size of 2 from the
Primary Key Field in the SupplierData Table.
3. In the first dialog box, select “I will type the values that I want”. Then click Next.
Page 18 of 25
4. In the second dialog box, type the two values as seen below and then click Next.
5. In the third dialog box, check the box for “Limit To List”. Then click Finish.
Page 19 of 25
ii. To Save the completed Products Table, use Ctrl + S.
iii. The Finished Products Table with Field Names, Data Types and Field Properties is seen in Design View is
seen here:
iv. Click the Datasheet View button to view the Datasheet view:
View button
to view the
Datasheet
view
v. The table has no raw data and shows no records. Click the Close Button to close the Products Table.
Page 20 of 25
6. Use Relationship Window to add "Referential Integrity" to One-To-Many Relationship between the two
Suppliers Code fields
vi. We need to edit the relationship that was created when we used the Lookup Wizard for the Supplier
Code in the Products Table. To edit a relationship, click the Relationships button in the Relationship
group in the Database Tools Ribbon Tab.
vii. In the Relationships Window, we can see that there is a Relationship Line between the Supplier Code
Fields in both the SupplierData Table Field List and the Products Table Field List.
viii. Using your cursor resize the Field Lists so that appear as they are in this picture:
Page 21 of 25
ix. Very carefully, hover your cursor over the Relationship Line and then Right-click and click on Edit
Relationship.
x. In the Edit Relationships dialog box, check the “Enforce Referential Integrity” check box to make sure
that you are ONLY allowed to enter a Supplier Code in the Products Table if it is already in the
SupplierData Table. This insures a One-To-Many Relationship.
xi. Note:
1. Cascade Delete Related Records check box
i. You cannot delete a record from a primary table if matching records exist in a related
table. For example, you can’t delete an employee record from the Employees table if
there are orders assigned to that employee in the Orders table. You can choose to
delete a primary record and all related records in one operation by selecting the
Cascade Delete Related Records check box.
2. Cascade Update Related Fields check box
i. You cannot change a primary key value in the primary table if doing so would create
orphan records. For example, you cannot change an order number in the Orders table if
there are line items assigned to that Order in the Order Details table. You can choose to
update a primary record and all related records in one operation by selecting the
Cascade Update Related Fields check box.
xii. We can see the One-To-Many Relationship. Next click the Close Relationship Window Button.
Page 22 of 25
7. Create a Form for the Products Table
xiii. We need a Form For each of the Tables so that we can enter, edit and delete data in each table. To
create a Form for the Products Table , select the Products Table in the Navigation Pane and then click
the Form button in the Forms group in the Create Ribbon Tab.
xiv. When the Form for the Products Table appears, click the View dropdown and then click on Form View.
xv. Save the Products Form by using the keyboard Ctrl + S. When the Save As dialog box appears, click OK.
xvi. Using the Close Button for the Products Form, close the Products Form:
Using the Close Button for the Products Form, close the Products Form
Page 23 of 25
xvii. The Product Form now appears in the Navigation Pane:
xviii. Repeating the steps for creating a Products Table Form, create a Form for the Supplier Data
Table. After you complete the SupplierData Form and close it, the Navigation Pane will contain two
tables and two formulas, like in this picture:
i. The next Page shows the Products Table after all the Raw Data is Entered.
ii. This is the end of Video #39.
iii. Next Video we will learn how to create Queries in Access.
Page 24 of 25
New Keyboards in Video
1. F6 = Jump from Field Name area to Field Properties area in Table Design View
Page 25 of 25