MS Access Essentials - Practical Slide 02 Part 01 and 02

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

MS Access Essentials

ICT 121 – Practical Session


By VPG Priyankara
Using Databases
• Since we have discussed on previous practical session how to create a
database, we will now create a database to use in upcoming practical
sessions.
• Please use this database over the course and make sure to keep It
safe for other upcoming practical sessions.
• If you have any aspect that you don’t understand, please ask form the
teacher and clarify it.
Creating A Database (05 Minutes)
1. Open MS Access in your computer. Choose, Blank desktop database.

2. MS Access will ask you to save the database. Save it under the name,
“Friends_Database_(Index No)”
Eg. Friends_Database_19SSL0000

1. Note: Save the file in a suitable location (D: drive or E: drive).


2. Upload you created file into your drive so you can use it in later
sessions.
_Index No
Create A Table (05 Minutes –Part 01)
1.Today, we’re going to create a table using Design View.
• Go to, View > Design View, and save the table under the
name, “Contacts”.

1.Change the data type accordingly.


• (e.g. Date_of_Birth – Date/Time)
Create A Table (10 Minutes –Part 02)
Use following fields with suitable data types
• Index_No
• First_Name
• Middle_Name
• Last_Name
• Full_Name
• Grade
• Gender
• Date_of_Birth
• Email
Create A Table
These are the datatypes you can use
• Index_No – Short Text
• First_Name – Short Text
• Middle_Name – Short Text
• Last_Name – Short Text
• Full_Name – Short Text
• Grade - Number
• Gender –Short Text
• Date_of_Birth –Date/Time
• Email – Short Text
Create A Table (10 Minutes –Part 03)
• Add a new field named “Picture”. Change the data type to
Attachment.
• Go to datasheet view. Save the table.
• Input 05 data according to your friends.
• Double Click attachment filed to add data into the table.
Creating a drop-down list (05 Minutes – Part 1)
• Make a drop down list for Gender field which will show “M”
and “F”.
• So that you can chose gender from that list.
• To do that, go to the design view of contacts table.
• Select Gender field and select data types as “Lookup Wizard”
• Choose “I will type the values that I want” in the popup
dialog box and Go to the next step.
Creating a drop-down list(05 Minutes – Part 2)
• Type the values that you
want to see (i.e. “M” and
“F”) in the drop down
menu in col1.

• Select Finish.
Creating a drop-down list (10 Minutes)
• Make a drop down list for the field Grade where it will show
a list from grade 3 to grade 12.
Creating an Expression (10 Minutes)
• Go to the table “Contacts”.
• we are going to create a Function/Expression (using Expression
Builder), where Microsoft Access will automatically join first
name and last name.
• Go to Design View.
• Delete the field “Full_Name”. (Because we already have data.)
• Create a new field and name it “Full_Name”.
• Select “Calculated” as the Data Type of Full name as seen in
next slide.
• Now, you will find a window
named Expression Builder as
shown as below.
• To join the two names, put
the following expression,

[First name] & “ “&[Last name]

Note: Here the double quotation


is for keeping a space between
first name and last name.

[First name] & “ “&[Last name]


Creating an Expression (15 Minutes)
• Now go to design view of the table again. And delete the full
name filed by selecting entire row.
• Next, create an Expression where First Name, Middle Name and
Last Name will automatically come together in the Full Name
field with spaces in-between.
Review Exercise(10 Minutes)
❑ Create a table named “Subject” and go to design view.
❑ Include the following fields with data type and description
• SubjectID (Auto Number)
• SubName -(Subject Name) (Text)
• SubjectCode – (Text)
• Deg_Year (Text)
• Sem(text)
• Teacher_ID (Number)

❑ Add the “Deg_Year” column data (1,2,3,4) as dropdown. And “Sem”


column data (1,2) as dropdown.
Review Exercise(10 Minutes)
❑ Do following changes to the table using the design view.

• Subject ID must be a primary key.


• Subject code must have 06 characters.(Field property “Field size”)
• Subject code must not be repeated.(Filed property “index”)

❑ Add 05 data to the table you created.


Creating Query (10 Minutes)
• Now we are going to create a Query in our database.

• Open the database file.


• Go to Create toolbar > Query Design
• Add Contacts table using add button.
• We want to run a query on “Full Name” and “Date of Birth”.
• From the table “Contacts” add “Full Name” and “Date of Birth” to
the Query field.(you can drag and drop them also)
• Run the Query.
• Save the query in name “Friend_Info”.
Creating Query
Modifying Query (10 Minutes)
• Now add field “Gender” in the Query and hide it using design
view.
• Add “Date_of_Birth” to the query and Make the appearance of
in ascending order.
• Run the query and see the changes are working.
Modifying Query (10 Minutes)

• Now, again go to query design of “Friend_Info” query.


• Add “First_Name” to the query design and show the “Gender”
column previously not shown.
• Now, Make the query show only “Full_Name” and
“Date_of_Birth”, where “Full_Name” starts with “A”
• Run the query and see if you get the correct results.
Modifying Query (05 Minutes)

• Next again modify the query and make the query show only
“Full_Name” and “Date_of_Birth”, where “Last_Name” starts
with “A” and gender is Female (F).
• Run the query and see if you get any results. If not, add some
data and try again running the query.
You do not need to You do not need to
add double add double
quotations (“ ”) quotations (“ ”)
Because access will Because access will
automatically add automatically add
them. them.
Review exercise(10 Minutes)
• Create a query for the “Subjects” Table.
• Show the all subject information and run the query.
• Then modify the query and show only “Sub_Code” and
“Sub_Name” and order subject names in ascending order.
• Save the query as “Subjects_Info”
Review exercise(10 Minutes)
• Use the previous Subject_Info query.
• Go to design view of the query and modify the query to show
“Sub_Code” and “Sub_Name”, where subject starts with “I” and
Run the query.
• Add a criteria to show the subject starts with “I” and Subject
Name starts with “A” and run the query.
Cont’d

You might also like