0% found this document useful (0 votes)
214 views16 pages

Lab Activity

This document provides instructions on creating tables, table relationships, and basic queries in Microsoft Access. It includes steps to create tables with fields and primary keys, establish relationships between tables, and build queries to view and sort data. Combo boxes are also configured to select customer names from a list to populate the customer ID field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
214 views16 pages

Lab Activity

This document provides instructions on creating tables, table relationships, and basic queries in Microsoft Access. It includes steps to create tables with fields and primary keys, establish relationships between tables, and build queries to view and sort data. Combo boxes are also configured to select customer names from a list to populate the customer ID field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

LAB ACTIVITY
MS ACCESS*
SESSION 1

Creating Table, Table Relationship


& Queries

Contents
1.1. Creating Table ................................................................................................................................................ 2

1.2. Creating Table Relationship ........................................................................................................................... 7

1.3. Creating Basic Queries ................................................................................................................................. 10

1.4. Creating Combo Box in Tables ..................................................................................................................... 13

In this guideline, you can see the name for tables, fields of table,
forms, queries, reports, macros and controls end with 000. REPLACE
the 000 with last three digit of your MATRIC NUMBER

* Best version Ms Access 2010

Page 1 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.1. Creating Table

1.1.1. In Create Tab, click Table

1.1.2.To add/edit the field, click Home tab and choose Design View

Page 2 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.1.3.Rename your table as sales_000

1.1.4. If you accidently put the table with different name, close the table first and right click the table
in Navigation Pane, choose rename.

(to close the table, right click at Table1 and click Close)

1.1.5. Set the Field Name and the Data Type

Page 3 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

Field Name Data Type

sale_id_000 AutoNumber

customer_id_000 Number

sale_date_000 Date/Time

1.1.6. You also can set more Field Properties – Example: Data Type Number has several
properties such as Format (General Numbers, Currency, Percent) by clicking General
tab in Field Properties. In this case, you can choose General Number or leave it
blank.

1.1.7.Primary key (key icon) – in this case sales_id_000 is normally set to AutoNumber
Page 4 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.1.8.To View the table, choose Datasheet View in Home tab.

1.1.9. Create another three tables.


1.1.9.1. Create sale items table by name: sale_items_000

Field Name Data Type

item_id_000 AutoNumber

sales_id_000 Number

product_id_000 Number

item_quantity_000 Number

item_price_000 Currency

1.1.9.2. Create customers table by name: customers_000

Field Name Data Type

customer_id_000 AutoNumber

customer_name_000 Text

customer_phone_000 Text

1.1.9.3. Create products table by name: products_000

Field Name Data Type

product_id_000 AutoNumber

product_name_000 Text

Page 5 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

product_price_000 Currency

1.1.10. Fill in some data in customers_000 table as example below (you can also put your own data). At
Home tab, choose Datasheet View to enter the data.

customer_name_000 customer_phone_000

Anis Suraya 013-123 451

Anne Hamid 013-123 452

Norman Hakim 013-123 453

Wardina Safiyyah 013-123 454

1.1.11. Fill in some data in products_000 table as example below (you can also put your own data)

product_name_000 product_price_000

Mouse 15.00

Keybord 55.00

Monitor 500.00

Scanner 45.00

VGA Cable 25.00

Page 6 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.2. Creating Table Relationship

1.2.1. Before you create table relationship, make sure the tables you want to relate with is closed. Click
Database Tools tab and choose Relationship

1.2.2.Double click table of sales_000 and customers_000 table

1.2.3. In this case, we see sales_000 table has foreign key of customer_id_000 that has
relationship with customer_id_000 in customers_000 table.

Page 7 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.2.4.Select customer_id_000 in sales_000 table and drag to customer_id_000 in


customers_000 table.
1.2.5.Check the Enforce Referential Integrity and click Create

1.2.6. Now you can see one-to-many relationship.


1.2.7. Save the table relationship

Field Key Table

customer_id_000 sales_000  customes_000

Page 8 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.2.8.Create another two table relationships

Field Key Table

sale_id_000 sale_items_000  sales_000

product_id_000 sale_items_000  producs_000

Page 9 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.3. Creating Basic Queries

1.3.1. In Create tab, click at Query Design.

1.3.2. Select customers_000 table.

1.3.3. Drag down or double click field that you wish to have. In this example, you need to
select customer_id_000 field and customer_name_000 field. You can sort the list
according to customer name

Page 10 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.3.4. The features of this query are as below:

Field customer_id_000 customer_name_000

Table customers_000 customers_000

Sort Ascending

Show YES YES

1.3.5. Finally put a name for the query as list_of_customer_000.

1.3.6. Click Run to see the result.

Page 11 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.3.7. Create another query by name list_of_product_000 using the setting as below.

Field product_id_000 product_name_000

Table products_000 products_000

Sort Ascending

Show YES YES

Page 12 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.4. Creating Combo Box in Tables


1.4.1. Now in sales_000 table, you have customer_id_000 field. It is difficult to fill in the
data because you need to remember the customer id to associate it with a customer
name. To solve this problem, we can create combo box to select customer name from
the list, but only store the customer id.

1.4.2. Open sales_000 table in Design View. Click Data Type of customer_id_000 field.

1.4.3. In Field Property, choose Lookup tab. Choose Combo Box option for Display/Control.

1.4.4. More option will appear in Field Property. Set Row Source Type to Table/Query.

1.4.5. You will see an option list_of_customer_000 is added to the Row Source. Select that option.

Page 13 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.4.6. Since this query has two columns, set some of options as below.

Column Count 2

Column Width 2cm;8cm

List Width 10cm

Page 14 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

1.4.7. Save the Table and open Datasheet view to see the result. You can select
from Combo Box from customer_id_000 field and the system just stores
customer id after you selected.

1.4.8. Now you have created combo box in sales_000 table. Repeat step 1.4.1 to 1.4.7 to
create combo box in product_id_000 field of sale_item_000 table using
list_of_product_000 query that you have created in 1.3.7.

Page 15 of 16
LAB ACTIVITY MS ACCESS SESSION 1 - Creating Table, Table Relationship, Query

THIS IS THE END OF THE TUTORIAL FOR SESSION 1

Page 16 of 16

You might also like