Top Banner
DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen a [email protected] March 19, 2015.
20

DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen [email protected] March 19, 2015.

Dec 27, 2015

Download

Documents

Chad Armstrong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

DAY 20:MICROSOFT ACCESS – CHAPTER 3 CONTD.

Aliya Farheen

[email protected]

March 19, 2015.

Page 2: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

ANNOUNCEMENT

• MyITLab Lesson D is due on 4/6/2015 Monday by 11:59 pm.

• Based on the Microsoft Word• Consist of seven chapters• Plan yourself to complete before due date.

Page 3: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

REMINDER

• Homework # 4 in Microsoft Access is now available at

http://cs101.wvu.edu/instructors/farheen/assignments/ • It is due by 4/3/2015 by 11.59 P.M.• Will have a homework review session in the next

class.

Page 4: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

TOTAL QUERIES

• “Totals” in a query can group field values and also perform basic computational functions on them

• To make the Total row appear, you need to click the Sigma symbol “Totals” button in query design view !

Page 5: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

EXERCISE

• Go to the lecture notes page and Download Total_example.accdb.

Page 6: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

PREMISE

We are running an investment firm and have some consultants working for us who have clients for which they manage investments.

We want a query that will show us how many clients each consultant has and the total amount of investments each consultant is handling…

• Save locally and open Total_example.accdb

Page 7: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

STRUCTURE OF TABLES & RELATIONSHIP

This Database has not yet had a relationship created. We will do it in the query for this one. Sometimes under special circumstances you will create them here instead of in the relationships window. Generally it is done in the relationships window though…

Page 8: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

BUILDING THE TOTAL QUERY

• Create ribbon > Other group > Query Design

• Add both tables• Create relationship inside query by

dragging ConsultantID fields together

Page 9: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

BUILDING THE TOTAL QUERY

• Add the field [Consultants]LastName• Add the field [Clients]LastName• Add the field [Clients]Assets• Run it without Total options > back to design

view• Click the button on the Query Tools /

Design ribbon to insert a “Total:” row• Note that the default for each is “Group

By”

Page 10: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

BUILDING THE TOTAL QUERY

• We will Group By the last name of the consultants to show each of them singularly

• We will Count the last names of the clients as they are tied to the consultants to show how many clients each has !

• We will Sum the assets of the clients to show how much all clients of each consultant have together

Page 11: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

SETTING UP THE TOTAL ROW

• Have [Consultants] LastName as Group By

• Have [Clients] LastName as Count• Have Assets as Sum

• Run the Query !

Page 12: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

ALIASING THE FIELD NAMES

• Sometimes for a Field, a Calculated field, or a Total field, we like to make the display name more specific in the query results

• To do this, simply change the field name in design view by adding a new name and an “:”

• An example for the clients LastName field:

# of Clients: LastName

Page 13: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

ALIAS THE 3 FIELDS IN DESIGN VIEW

• Consultant: LastName• # Clients: LastName• Total Assets: Assets• Run the Query and note the field names in

the dynaset !

Page 14: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

DOING MULTIPLE THINGS TO 1 FIELD

• Sometimes you may need to do multiple total query-type actions to a single field.

• Download and open the file CSDemo.accdb from the site

Page 15: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

BACKGROUND FOR TOTAL QUERY

• Look at the contents of the Sales table

We want to display our:• Number of sales• Total dollar amount of sales• Average dollar amount sale

Page 16: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

CREATING THE TOTAL QUERY

• Create a new query in design view• Add the Sales Table• Add the Amount field 3 Times ! ! !• Click button to show the Total row• Set them to Count, Sum, and Average

• Run it !• Close Access

Page 17: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

IMPORTING XML DATA TO TABLES

• Download and save Bands.xml file on the desktop

• External Data Ribbon > Import group > XML File

• Browse for the xml file• Select Open & OK

Page 18: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

IMPORTING XML FILES

• Verify Structure and Data is checked• This brings in the table & its records• Later in the course we will use other options

• Click OK and Close• Open the table in the database !

Page 19: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

IN CLASS PROJECT

• Go to todays lecture notes • Download the data file

Save the database file on to computer • Collect the instruction file• Start working on the Queries Project !

Page 20: DAY 20: MICROSOFT ACCESS – CHAPTER 3 CONTD. Aliya Farheen aliya.farheen@mail.wvu.edu March 19, 2015.

Questions ?