SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Introduction to Microsoft Access
                                Part 2 – Queries

One of the main reasons why computerised databases are useful is their ability to find
                      the information what you want quickly.



1. Sorting


Sorting simply puts the records in a sensible order.

1. Click in the Field you want to Sort

2. Either use the two buttons on the toolbar or select Sort from the Records menu.




You need to select either Sort Ascending or Sort Descending.

Sort Ascending sorts alphabetically from A-Z or numerically from smallest to
largest.

Sort Descending sorts reverse-alphabetically from Z-A or numerically from largest to
smallest.



Your Task

A limitation of the Sort function is when you have letters mixed with numbers. Try
entering these addresses into a table. Use the Sort function and record what happens:

12 Bond Street
24 Regent Street
36 Ashford Road
345 Benfleet Road
140 Ash Avenue
15 York Road
16 Market Street



Page 1 of 19                                                                 04/07/12
2. Finding Data in Tables

1. Start by entering some more data into the Artists table, as follows:




2. The simplest find of all is to click in a column and press CTRL+F (alternatively,
select FIND from the EDIT menu.

3. Enter some text to search
for and click Find First




4. By default, Access searches only in the field you clicked in before you started the
Find. Untick the Search only the Current Field box if you want to search the whole
table.

5. If you are finding that there are too many matches, use Search Up or Search
Down to search from the current record.

6. By default, Access looks for records that contain only an exact match of your text.
This means, for example, that if you searched for Rob your search would not find
Robbie. Bill would not find Billy, and so on. If you want to widen your search, look
at the options in the Match box.

7. Match Case makes the search case sensitive. With this option activated, a search
for McNulty would find neither MCNULTY nor mcnulty.

For Discussion

In any Access search, you can search for a "wildcards". Wildcards match patterns.
For example, you can use the # symbol to represent a number. # # Shipwrights
Drive would find 10 Shipwrights Drive but not 9 Shipwrights Drive. Why not?


Page 2 of 19                                                                 04/07/12
3. Filtering: Filter By Selection


Filters group together records that share something in common.

There are three methods of filtering: filter by selection, filter by form and Advanced
Filter/Sort. We will go through each in turn.

Note: Although the examples here are used on tables, filters can also be applied to
forms, queries and records.

1. Find one recording artist who is American and highlight the word American.

2. Either click the Filter By Selection button on the toolbar or go to Records ►
Filters ► Filter By Selection.




You should now see a table listing only American musicians.




3. Click the Remove Filter button on the toolbar to return to the complete table


Your Task

Using the Filter By Selection tool, see if you can generate a list of British musicians.
Is Robbie Williams in your list? Why not?



Page 3 of 19                                                                  04/07/12
4. Filtering: Filter By Form


Filter By Form is more flexible than Filter By Selection, as we shall see.

1. Start by clicking the Filter By Form button or go to Records ► Filters ► Filter
By Form.




2. You should notice that a Look For tab is at the bottom of the window and also that
an upside down arrow appears in whichever field you select.




3. Using the Filter By Form you can set Search Criteria, for example, you can tell
Access to look for Artists who are English Or British (so you make sure you include
Robbie Williams). You could ask for a list of Australians who are also called Rolf
Harris.

4. Click the Apply Filter button when you want to run the filter and the Remove
Filter button when you want to return to the full table.


        The Clear Grid button lets you start again if you make a mistake.



        The Remove Filter button and the Apply Filter button both look like this.
        Because you only use them one at a time, this shouldn’t be confusing!


Your Task

Using Filter By Form, generate a list of Artists who are either American or
Australian



Page 4 of 19                                                                 04/07/12
5. Filtering: Advanced Filter/Sort


Advanced Filter/Sort is almost a query. Its only limitation is that you can only work
with one table at a time.

1. Start by going to Records ► Filters ► Filter By Form.




2. You will see a Field List in the top half of the window and blank Query Grid in
the bottom half.

3. Add the field or fields that you want to filter. You can add one or more fields. Add
a field by double-clicking the field name in the Field List or by selecting it from the
drop-down list.

If you want to add all the fields at once, double click on the heading in the Field List
and drag the fields to the Query Grid.

4. You can set an Ascending or Descending sort for each field. This will control the
way the order in which the filter results are listed. If more than one field is selected,
the Sort will work from left to right in the Query Grid.

5. You can set your search criteria in inverted commas. This search is going to look
for artists who are Australian or American.




Page 5 of 19                                                                   04/07/12
Select Delete Columns from the Edit menu, if you want to remove a column from the
Query Grid.

Click the Clear Grid button if you want to clear the whole Query Grid.

Click the Apply Filter button to run the filter and the Remove Filter button to return
to the full table.

Click the Save As Query button, if you want to save the filter for later use.


Boolean Operators

AND     Finds examples of both      e.g. American AND Australian finds
                                    artists who are both American and
                                    Australian (will produce zero results)
 OR Finds examples of either        e.g. American OR Australian finds
                                    records artists who are either American or
                                    Australian
 IS  Finds exact matches only       e.g. IS Rolf Harris finds records which
                                    contain both names
LIKE Finds any record that contains e.g. LIKE Rolf finds any artist called
     the term somewhere.            Rolf
  >  Greater than                   e.g. in a money or field <30 would show
                                    all numbers below 30
  <  Less than                      e.g. >30 lists all numbers over 30
 > = Greater than or equal to       e.g. >=30 lists all numbers from 30
 < = Less than or equal to          e.g. <=30 lists all numbers that are 30 or
                                    less than 30
 <>  Not Equal                      e.g. <> 30 lists all numbers except 30
  =  Equals                         e.g. =30 lists only 30

Your Task

Open a larger database, such as the Northwind database (this is a sample database
that Microsoft supply with Access.

Open the Products table and do an Advanced Filter/Sort to find:
   • Items with more than 50 units in stock
   • Condiments that cost more than $20.00
   • Seafood products that come from Escargots Nouveaux or Tokyo Traders or
       New England Seafood Cannery of which there are least 30 units in stock.


For Discussion

Arithmetic operators can be applied to text and date fields. For example, LAST
NAME >"G" finds everyone with surnames from G to Z. Why doesn't it pick up Ali
G?



Page 6 of 19                                                                    04/07/12
6. How to Create a Simple Query


Creating a query is easier than using Advanced Filter/Sort because:
   • The results of the query are automatically saved.
   • You can use the Simple Query Wizard to design the query
   • You can use multiple tables

1. Click on the Queries tab of the Database Window.

2. Click the New button and select Simple Query Wizard.




3. Choose your tables and fields.

4. If you want to add sorting and search criteria, you must open the Query in Design
View.

5. A very useful feature to note is the Top Values box, into which you can type a
number or a percentage.




          Click the Run button to run the Query


Your Task

Using the Northwind database, create a query to show the 20 most expensive
products.




Page 7 of 19                                                               04/07/12
7. More Complex Queries


1. You can design a query that combines fields from more than one table, as long as
the tables are related. Create the relationships before you create the query.

2. You can create a query to show items between two values. For example, the
following Query shows orders between two specified dates:




Your Task

Using the Northwind database, create a query to show all orders in the second half of
1996. Use the Customers and the Orders tables to show the details of who made
these orders.


3. Boolean Operators can be used across columns. It is important to remember the
difference between AND/OR operations.

AND operations restrict your search. OR operations widen the search.

You can combine AND/OR operations. The query below looks for orders that were
made between two dates AND were made by customers from the UK OR France OR
Canada.




Page 8 of 19                                                                04/07/12
Your Task

1. Open the Query from the previous task

2. Make sure the Country field is included in the query. Add it if necessary.

3. Restrict the query to show only orders made by customers in Germany or Denmark
or Austria.

4. Click the Design View button to make a further change to your search criteria.

5. Refine your query so that it shows orders made by customers in Germany or
Denmark or Austria AND with the company name “Drachenblut Delikatessen” (the
query should show only one order).


4. Using the OR operator in one column is easy but it becomes more complicated if.
If you want to widen the search by adding an OR over several columns, you need to
put the OR on a separate line.

For example, this query shows orders made between two dates and all orders made by
London companies:




Your Task

1. In the example above, what would be the result if “London” were put in the
Criteria row?

2. How good a salesperson is Nancy Davolio? Produce a query to show all orders
that she took in 1994 that were over £50 in value.




Page 9 of 19                                                                    04/07/12
8. Counting Queries


To get your queries to do calculations, you start the query as normal, select the tables
and fields you are going to use and then press the Sigma Button (∑) to make the
Total Row appear.

You need to have a field or fields to Group By. This function tells Access that you
want to organise the information you are displaying into groups. You can group by
several fields. You also need a field on which to perform a function

The Count function simply tells you how many records are in each group. For
example, the following query tells you how many customers are in each country:




The following query will add together the daily value of UK orders, using the Sum
function:




Your Task

1. Using your Music database, do a query to count how many different artists you
have in your database.

2. Using the Northwind database, calculate the total value of all orders made in
1996.


Page 10 of 19                                                                 04/07/12
You can use a Search Criteria in any field, including a Group By field. The
following query, searches for products that cost more than $100




                         Access Functions and What They Do
Group By        Organises the query results
  Sum           Adds up all the values in the field
   Avg          Calculates the average values
   Min          Returns the lowest value
  Max           Returns the highest value
  Count         Shows the number of records that match the query criteria
  First         Returns the first value that Access finds
   Last         Returns the last value that Access finds
Expression      Creates a calculated field
 Where          Uses the field as part of the search criteria but does not display the field
                itself in the results of the query




Your Task

1. Create a list of products that cost less than $50

2. Find the average price of Northwind’s products

3. Show the most expensive product only




Page 11 of 19                                                                     04/07/12
9. Crosstab Queries


Crosstab queries are used to summarise data in tables. It has a rows and columns
format, where you can think of each row as a record and each column as a field
describing that record. Unlike a table, however, there is an additional column that
performs a calculation on the data.

For example, you might create a crosstab query based on a table of sales orders.
Products could be shown in rows and the Order Date in columns. You would also
have a calculating column to Sum the values. The calculating column would provide
a total value for each product.

A crosstab query can be based on tables or queries.

1. You want to show the total value of the sales of each of Northwind’s products for
each year. First, create a query that combines data from the Orders and Order
Details tables. You need the name of the product, the dates on which the product was
ordered and the value of each order.

2. Start the Crosstab Query Wizard.

3. Select the query that you just created.

4. You want to use the name of the product as the row heading.




5. Use the order date for the column headings.

6. Group the orders together by year.

7. The Wizard then asks you what number you want to be calculated at the
intersection of each row and column. You want to add together the value of the
orders.


Page 12 of 19                                                              04/07/12
10. Calculated Fields


A calculated field takes numbers from other fields in the query and performs a
calculation on them.

You can add a calculated field to a query, as long as you include in the query all the
data that the calculated field needs to perform its calculation.

A calculated field can take data from more than one field.

Calculated fields are ideal for performing “What if?” queries. For example, “what
would our prices be if we increased all prices by 5%?”

1. To answer this question, use the Northwind database and create a new query using
the Products Table.

2. You need the name of the product and the price of the product in the query.

3. Type [UnitPrice]*1.05 as the field name in a new field:




4. Run the query by clicking the Run Button. You will notice that your field name
has been given the name Expr1, which isn’t very descriptive and the numbers in the
column are not formatted as currency. Click the Design View button to remedy this.

5. Double click Expr1 to select it and change the name to New Price.

6. Click the Properties Button

Change the Format of the field to
Currency.

In the Description Box type: Shows
prices raised by 5%. Close the
Properties.




Page 13 of 19                                                                04/07/12
7. Run the Query again and you will see the effect of your changes. When you click
in the New Price field, you will see the Description Text appear in the Status Bar at
the bottom-left of the Access window.


Your Task

The accounting department at Northwind want to know the value of each product that
is on order. Produce a query with a calculated field that will show this.


8. Of course, the company could be awkward and reduce the prices by 4.5%, and then
they might change their minds again. This needn’t be a worry to you if you make
Access ask for a percentage value before running the calculation.

To achieve this, simply make up the name of a field, for example “PercentIncrease”
and include that in the expression in place of the figure. For example:

                     New Price: [UnitPrice]*[Percent Increase]

Now, when the query runs, it asks for a percentage increase and calculates the results
accordingly.




Your Task

Northwind are considering reducing their prices for a month. Produce a query with a
calculated field that will allow the accounting department to see the effect of a
percentage decrease in the value of orders.

9. You can calculate with text fields as well as with numbers. A common use for this
is when you want to combine the FirstName and LastName fields. You would
simply enter:

                            [FirstName]+" "+[LastName]

N.B. the space between the quotation marks tells Access to leave a space between first
name and last name.

Your Task

Create a list of customers with their titles in brackets. For example:
Maria Anders (Sales Representative)

Hint: Click the Build button on the toolbar to use the Expression Builder.


Page 14 of 19                                                                 04/07/12
11. Other Types of Queries


A Select Query is the commonest type of query. It answers questions about your
data.

An Action Query is a query that makes changes to your data.

Simple jobs don't need complicated solutions. If you want to change every instance
of a word or phrase, throughout a field, you can open a table, select a field and then
select Replace from the Edit Menu (or use CRTL+H).

In Find What: enter a word or
phrase to search for.
In Replace With: enter a word or
phrase to replace it with.
The other options in this dialog box
are the same as for the Find feature.


Your Task

In the Customers Table of the Northwind Database change every example of the
entry Owner to Proprietor.


More complicated and widespread changes should be
made with the appropriate type of Query. When you
create a new query, Access gives you a Select Query.
You can change the Query Type by opening the Query
Menu and selecting a different type of query or you can
use the Query Type drop-down list.




You will recognise the Crosstab Query because you have used it before.

The last four types of queries are listed with an exclamation mark to remind you that
they actually change the way your information is organised. You should not run these
queries unless you have first previewed the changes and unless you also have a
backup.


The Run button executes the query. All changes are saved automatically.

The View button allows you to preview the query without saving the
changes.




Page 15 of 19                                                                04/07/12
12. The Delete Query


The delete query is the easiest type of action query to use and it is also the most
dangerous!

1. Create a normal select query and add the fields you want. Preview the query when
finished and click the View button to preview the changes.

2. Change the Query type from Select to Delete. You will notice that the Sort line
changes to a Delete line.

3. Enter your criteria to delete. The following example, will remove records of
customers located in France or Canada.




4. Click the View button and you will see a list of records that would be deleted if
you were brave enough to click the Run button. If you are sure you want to delete
these records, click the Design button and then click the Run button. Access will
give you one last chance to change your mind and then your records will be trashed.


Your Task

In an act of blatant ageism, Northwind decide to sack all employees who were born
before 1960. Create a Delete query that will remove these employees from the
database. Preview the results but don't run the query.




Page 16 of 19                                                              04/07/12
13. The Update Query


An update query allows you to create a query to select records and then change those
records according to an instruction.

1. Create a select query first, preview it and then change the query type to Update
Query. You will notice that the Sort line changes to an Update line.

2. Enter an instruction in the Update Line telling
Access what to do with the records you have
selected.

This query will apply a 10% discount to all
products over $100.




3. Clicking the View button will show you a list of the records that will be changed,
should you decide to click the Run button.


Your Task

Increase the prices of all products in the Northwind Database that are over $50 by
10%


4. The other query types are less commonly used. Once you have got the hang of the
Delete Query and the Update Query, these should not cause you too many
problems:


 Make Table Query        Saves the results of a query as an additional table. This is
                         useful for exporting information to another database.
   Append Query          Allows you to add information from a query to an existing
                         table. In the Criteria line, you could, for example, append
                         only those customers with unpaid bills.
   Find Duplicates       From the results of a Find Duplicates query, you can
       Query             determine if there are duplicate records in a table, or
                         determine which records in a table share the same value.
                         Use the Find Duplicates Query Wizard.
  Find Unmatched         Using the Find Unmatched Query Wizard, you can find
       Query             records in one table that don't have related records in another
                         table. For example, you can find customers who don't have


Page 17 of 19                                                                 04/07/12
orders. Use the Find Unmatched Query Wizard.
14. Keyboard Shortcuts


F2              Select an entire field
Ctrl+;          Insert the Current Date
Ctrl+:          Insert the Current Time
Ctrl+Enter      Insert a Line Break (use it in a memo or large text field)
Ctrl++          Add New Record
Ctrl+-          Delete the Current Record
Shift+Enter     Save the Record
Ctrl+Z          Undo the last change you made (don't rely on this)
Ctrl+Enter      Open the selected object in Design View
Alt+F4          Quit Access




15. Summary (from the Access Help file)




Page 18 of 19                                                                04/07/12
Page 19 of 19   04/07/12

Weitere ähnliche Inhalte

Was ist angesagt? (19)

Libre Office Writer Lesson 3: Using Styles and Templates
Libre Office Writer Lesson 3: Using Styles and TemplatesLibre Office Writer Lesson 3: Using Styles and Templates
Libre Office Writer Lesson 3: Using Styles and Templates
 
Ms excel short key
Ms excel short keyMs excel short key
Ms excel short key
 
Part II: Volume Control
Part II: Volume ControlPart II: Volume Control
Part II: Volume Control
 
Word shortcuts
Word shortcutsWord shortcuts
Word shortcuts
 
MS Excel 2010 tutorial 6
MS Excel 2010 tutorial 6MS Excel 2010 tutorial 6
MS Excel 2010 tutorial 6
 
Basic excel training
Basic excel trainingBasic excel training
Basic excel training
 
MS Excel 2nd
MS Excel 2ndMS Excel 2nd
MS Excel 2nd
 
Microsoft Word Home tab Presentation
Microsoft Word Home tab PresentationMicrosoft Word Home tab Presentation
Microsoft Word Home tab Presentation
 
Ms office 2013
Ms office 2013Ms office 2013
Ms office 2013
 
Libre Office Writer Lesson 2
Libre Office Writer Lesson 2Libre Office Writer Lesson 2
Libre Office Writer Lesson 2
 
Excel training
Excel  training Excel  training
Excel training
 
Excel 2010
Excel 2010Excel 2010
Excel 2010
 
MS Excel 2010 tutorial 3
MS Excel 2010 tutorial 3MS Excel 2010 tutorial 3
MS Excel 2010 tutorial 3
 
MS Excel 2010 tutorial 2
MS Excel 2010 tutorial 2MS Excel 2010 tutorial 2
MS Excel 2010 tutorial 2
 
Excel shortcuts
Excel shortcutsExcel shortcuts
Excel shortcuts
 
Excel
ExcelExcel
Excel
 
MS Word Advanced Training
MS Word Advanced TrainingMS Word Advanced Training
MS Word Advanced Training
 
Ms Excel AZC
Ms Excel AZCMs Excel AZC
Ms Excel AZC
 
MS Excel 2010 tutorial 4
MS Excel 2010 tutorial 4MS Excel 2010 tutorial 4
MS Excel 2010 tutorial 4
 

Andere mochten auch

Doublebookings1
Doublebookings1Doublebookings1
Doublebookings1JTHSICT
 
E book example
E book exampleE book example
E book exampleJTHSICT
 
Kpn questionnaire
Kpn questionnaireKpn questionnaire
Kpn questionnairesalaimamani
 
Provably secure nested one time secrete key
Provably secure nested one time secrete keyProvably secure nested one time secrete key
Provably secure nested one time secrete keysalaimamani
 
Doublebookings2
Doublebookings2Doublebookings2
Doublebookings2JTHSICT
 
Literacy glossary
Literacy glossaryLiteracy glossary
Literacy glossaryJTHSICT
 
Validation
ValidationValidation
ValidationJTHSICT
 
5 things every retailer should know
5 things every retailer should know5 things every retailer should know
5 things every retailer should knowLeavs Ltd
 
Carbon report-slideshow
Carbon report-slideshowCarbon report-slideshow
Carbon report-slideshowLeavs Ltd
 
It4 Coursework Help
It4 Coursework HelpIt4 Coursework Help
It4 Coursework HelpJTHSICT
 

Andere mochten auch (19)

Doublebookings1
Doublebookings1Doublebookings1
Doublebookings1
 
Access2
Access2Access2
Access2
 
Access3
Access3Access3
Access3
 
E book example
E book exampleE book example
E book example
 
Kpn questionnaire
Kpn questionnaireKpn questionnaire
Kpn questionnaire
 
Provably secure nested one time secrete key
Provably secure nested one time secrete keyProvably secure nested one time secrete key
Provably secure nested one time secrete key
 
Access1
Access1Access1
Access1
 
Finance report
Finance reportFinance report
Finance report
 
Access1
Access1Access1
Access1
 
Access4
Access4Access4
Access4
 
Doublebookings2
Doublebookings2Doublebookings2
Doublebookings2
 
Literacy glossary
Literacy glossaryLiteracy glossary
Literacy glossary
 
Access5
Access5Access5
Access5
 
Validation
ValidationValidation
Validation
 
5 things every retailer should know
5 things every retailer should know5 things every retailer should know
5 things every retailer should know
 
Macros
MacrosMacros
Macros
 
Carbon report-slideshow
Carbon report-slideshowCarbon report-slideshow
Carbon report-slideshow
 
It4 Coursework Help
It4 Coursework HelpIt4 Coursework Help
It4 Coursework Help
 
Globalization
GlobalizationGlobalization
Globalization
 

Ähnlich wie Access2

Filter Data in Excel Services SharePoint 2010 - EPC Group
Filter Data in Excel Services SharePoint 2010 - EPC GroupFilter Data in Excel Services SharePoint 2010 - EPC Group
Filter Data in Excel Services SharePoint 2010 - EPC GroupEPC Group
 
Microsoft Office Excel 2003 Sorting And Filtering
Microsoft Office Excel 2003 Sorting And FilteringMicrosoft Office Excel 2003 Sorting And Filtering
Microsoft Office Excel 2003 Sorting And FilteringMarc Morgenstern
 
How to create lists in millennium july 2011
How to create lists in millennium july 2011How to create lists in millennium july 2011
How to create lists in millennium july 2011nybglibrary
 
Lesson 10 - Sorting , Grouping and Filtering Cells
Lesson 10 - Sorting , Grouping and Filtering CellsLesson 10 - Sorting , Grouping and Filtering Cells
Lesson 10 - Sorting , Grouping and Filtering Cellsguevarra_2000
 
Microsoft excel training
Microsoft excel trainingMicrosoft excel training
Microsoft excel trainingMohamed Hassan
 
Microsoft Access Notes 2007 Ecdl
Microsoft Access Notes 2007 EcdlMicrosoft Access Notes 2007 Ecdl
Microsoft Access Notes 2007 EcdlRichard Butler
 
Create A Drop Down List In Excel
Create A Drop Down List In ExcelCreate A Drop Down List In Excel
Create A Drop Down List In ExcelChester Tugwell
 
Microsoft access exercises
Microsoft access exercisesMicrosoft access exercises
Microsoft access exercisessarahandaiza
 
Project Fusion Reference Guide V2
Project Fusion Reference Guide V2Project Fusion Reference Guide V2
Project Fusion Reference Guide V2dnmiller
 
Splitter Pro X version Tutorial June 2020 English
Splitter Pro X version Tutorial June 2020 EnglishSplitter Pro X version Tutorial June 2020 English
Splitter Pro X version Tutorial June 2020 EnglishAdhi Wikantyoso
 
Excel database
Excel databaseExcel database
Excel databasegdcs
 

Ähnlich wie Access2 (20)

Filter Data in Excel Services SharePoint 2010 - EPC Group
Filter Data in Excel Services SharePoint 2010 - EPC GroupFilter Data in Excel Services SharePoint 2010 - EPC Group
Filter Data in Excel Services SharePoint 2010 - EPC Group
 
Microsoft Office Excel 2003 Sorting And Filtering
Microsoft Office Excel 2003 Sorting And FilteringMicrosoft Office Excel 2003 Sorting And Filtering
Microsoft Office Excel 2003 Sorting And Filtering
 
Naval PPT.pptx
Naval PPT.pptxNaval PPT.pptx
Naval PPT.pptx
 
MS Access 2010 tutorial 5
MS Access 2010 tutorial 5MS Access 2010 tutorial 5
MS Access 2010 tutorial 5
 
How to create lists in millennium july 2011
How to create lists in millennium july 2011How to create lists in millennium july 2011
How to create lists in millennium july 2011
 
Lesson 10 - Sorting , Grouping and Filtering Cells
Lesson 10 - Sorting , Grouping and Filtering CellsLesson 10 - Sorting , Grouping and Filtering Cells
Lesson 10 - Sorting , Grouping and Filtering Cells
 
Priyank Goel PPT.pptx
Priyank Goel PPT.pptxPriyank Goel PPT.pptx
Priyank Goel PPT.pptx
 
Access 2007 lecture notes students
Access 2007 lecture notes studentsAccess 2007 lecture notes students
Access 2007 lecture notes students
 
Print10
Print10Print10
Print10
 
Microsoft excel training
Microsoft excel trainingMicrosoft excel training
Microsoft excel training
 
Microsoft Access Notes 2007 Ecdl
Microsoft Access Notes 2007 EcdlMicrosoft Access Notes 2007 Ecdl
Microsoft Access Notes 2007 Ecdl
 
12045217.ppt
12045217.ppt12045217.ppt
12045217.ppt
 
Create A Drop Down List In Excel
Create A Drop Down List In ExcelCreate A Drop Down List In Excel
Create A Drop Down List In Excel
 
Microsoft access exercises
Microsoft access exercisesMicrosoft access exercises
Microsoft access exercises
 
Basic Data Handling
Basic Data HandlingBasic Data Handling
Basic Data Handling
 
Project Fusion Reference Guide V2
Project Fusion Reference Guide V2Project Fusion Reference Guide V2
Project Fusion Reference Guide V2
 
How to Filter in Excel
How to Filter in ExcelHow to Filter in Excel
How to Filter in Excel
 
Splitter Pro X version Tutorial June 2020 English
Splitter Pro X version Tutorial June 2020 EnglishSplitter Pro X version Tutorial June 2020 English
Splitter Pro X version Tutorial June 2020 English
 
Excel database
Excel databaseExcel database
Excel database
 
MS ACCESS PPT.pptx
MS ACCESS PPT.pptxMS ACCESS PPT.pptx
MS ACCESS PPT.pptx
 

Mehr von JTHSICT

Year 8 sow 2012 2013
Year 8 sow 2012 2013Year 8 sow 2012 2013
Year 8 sow 2012 2013JTHSICT
 
Lookup table
Lookup tableLookup table
Lookup tableJTHSICT
 
Password
PasswordPassword
PasswordJTHSICT
 
Naming conventions
Naming conventionsNaming conventions
Naming conventionsJTHSICT
 
Normalization
NormalizationNormalization
NormalizationJTHSICT
 
Calendar
CalendarCalendar
CalendarJTHSICT
 

Mehr von JTHSICT (6)

Year 8 sow 2012 2013
Year 8 sow 2012 2013Year 8 sow 2012 2013
Year 8 sow 2012 2013
 
Lookup table
Lookup tableLookup table
Lookup table
 
Password
PasswordPassword
Password
 
Naming conventions
Naming conventionsNaming conventions
Naming conventions
 
Normalization
NormalizationNormalization
Normalization
 
Calendar
CalendarCalendar
Calendar
 

Kürzlich hochgeladen

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 

Kürzlich hochgeladen (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 

Access2

  • 1. Introduction to Microsoft Access Part 2 – Queries One of the main reasons why computerised databases are useful is their ability to find the information what you want quickly. 1. Sorting Sorting simply puts the records in a sensible order. 1. Click in the Field you want to Sort 2. Either use the two buttons on the toolbar or select Sort from the Records menu. You need to select either Sort Ascending or Sort Descending. Sort Ascending sorts alphabetically from A-Z or numerically from smallest to largest. Sort Descending sorts reverse-alphabetically from Z-A or numerically from largest to smallest. Your Task A limitation of the Sort function is when you have letters mixed with numbers. Try entering these addresses into a table. Use the Sort function and record what happens: 12 Bond Street 24 Regent Street 36 Ashford Road 345 Benfleet Road 140 Ash Avenue 15 York Road 16 Market Street Page 1 of 19 04/07/12
  • 2. 2. Finding Data in Tables 1. Start by entering some more data into the Artists table, as follows: 2. The simplest find of all is to click in a column and press CTRL+F (alternatively, select FIND from the EDIT menu. 3. Enter some text to search for and click Find First 4. By default, Access searches only in the field you clicked in before you started the Find. Untick the Search only the Current Field box if you want to search the whole table. 5. If you are finding that there are too many matches, use Search Up or Search Down to search from the current record. 6. By default, Access looks for records that contain only an exact match of your text. This means, for example, that if you searched for Rob your search would not find Robbie. Bill would not find Billy, and so on. If you want to widen your search, look at the options in the Match box. 7. Match Case makes the search case sensitive. With this option activated, a search for McNulty would find neither MCNULTY nor mcnulty. For Discussion In any Access search, you can search for a "wildcards". Wildcards match patterns. For example, you can use the # symbol to represent a number. # # Shipwrights Drive would find 10 Shipwrights Drive but not 9 Shipwrights Drive. Why not? Page 2 of 19 04/07/12
  • 3. 3. Filtering: Filter By Selection Filters group together records that share something in common. There are three methods of filtering: filter by selection, filter by form and Advanced Filter/Sort. We will go through each in turn. Note: Although the examples here are used on tables, filters can also be applied to forms, queries and records. 1. Find one recording artist who is American and highlight the word American. 2. Either click the Filter By Selection button on the toolbar or go to Records ► Filters ► Filter By Selection. You should now see a table listing only American musicians. 3. Click the Remove Filter button on the toolbar to return to the complete table Your Task Using the Filter By Selection tool, see if you can generate a list of British musicians. Is Robbie Williams in your list? Why not? Page 3 of 19 04/07/12
  • 4. 4. Filtering: Filter By Form Filter By Form is more flexible than Filter By Selection, as we shall see. 1. Start by clicking the Filter By Form button or go to Records ► Filters ► Filter By Form. 2. You should notice that a Look For tab is at the bottom of the window and also that an upside down arrow appears in whichever field you select. 3. Using the Filter By Form you can set Search Criteria, for example, you can tell Access to look for Artists who are English Or British (so you make sure you include Robbie Williams). You could ask for a list of Australians who are also called Rolf Harris. 4. Click the Apply Filter button when you want to run the filter and the Remove Filter button when you want to return to the full table. The Clear Grid button lets you start again if you make a mistake. The Remove Filter button and the Apply Filter button both look like this. Because you only use them one at a time, this shouldn’t be confusing! Your Task Using Filter By Form, generate a list of Artists who are either American or Australian Page 4 of 19 04/07/12
  • 5. 5. Filtering: Advanced Filter/Sort Advanced Filter/Sort is almost a query. Its only limitation is that you can only work with one table at a time. 1. Start by going to Records ► Filters ► Filter By Form. 2. You will see a Field List in the top half of the window and blank Query Grid in the bottom half. 3. Add the field or fields that you want to filter. You can add one or more fields. Add a field by double-clicking the field name in the Field List or by selecting it from the drop-down list. If you want to add all the fields at once, double click on the heading in the Field List and drag the fields to the Query Grid. 4. You can set an Ascending or Descending sort for each field. This will control the way the order in which the filter results are listed. If more than one field is selected, the Sort will work from left to right in the Query Grid. 5. You can set your search criteria in inverted commas. This search is going to look for artists who are Australian or American. Page 5 of 19 04/07/12
  • 6. Select Delete Columns from the Edit menu, if you want to remove a column from the Query Grid. Click the Clear Grid button if you want to clear the whole Query Grid. Click the Apply Filter button to run the filter and the Remove Filter button to return to the full table. Click the Save As Query button, if you want to save the filter for later use. Boolean Operators AND Finds examples of both e.g. American AND Australian finds artists who are both American and Australian (will produce zero results) OR Finds examples of either e.g. American OR Australian finds records artists who are either American or Australian IS Finds exact matches only e.g. IS Rolf Harris finds records which contain both names LIKE Finds any record that contains e.g. LIKE Rolf finds any artist called the term somewhere. Rolf > Greater than e.g. in a money or field <30 would show all numbers below 30 < Less than e.g. >30 lists all numbers over 30 > = Greater than or equal to e.g. >=30 lists all numbers from 30 < = Less than or equal to e.g. <=30 lists all numbers that are 30 or less than 30 <> Not Equal e.g. <> 30 lists all numbers except 30 = Equals e.g. =30 lists only 30 Your Task Open a larger database, such as the Northwind database (this is a sample database that Microsoft supply with Access. Open the Products table and do an Advanced Filter/Sort to find: • Items with more than 50 units in stock • Condiments that cost more than $20.00 • Seafood products that come from Escargots Nouveaux or Tokyo Traders or New England Seafood Cannery of which there are least 30 units in stock. For Discussion Arithmetic operators can be applied to text and date fields. For example, LAST NAME >"G" finds everyone with surnames from G to Z. Why doesn't it pick up Ali G? Page 6 of 19 04/07/12
  • 7. 6. How to Create a Simple Query Creating a query is easier than using Advanced Filter/Sort because: • The results of the query are automatically saved. • You can use the Simple Query Wizard to design the query • You can use multiple tables 1. Click on the Queries tab of the Database Window. 2. Click the New button and select Simple Query Wizard. 3. Choose your tables and fields. 4. If you want to add sorting and search criteria, you must open the Query in Design View. 5. A very useful feature to note is the Top Values box, into which you can type a number or a percentage. Click the Run button to run the Query Your Task Using the Northwind database, create a query to show the 20 most expensive products. Page 7 of 19 04/07/12
  • 8. 7. More Complex Queries 1. You can design a query that combines fields from more than one table, as long as the tables are related. Create the relationships before you create the query. 2. You can create a query to show items between two values. For example, the following Query shows orders between two specified dates: Your Task Using the Northwind database, create a query to show all orders in the second half of 1996. Use the Customers and the Orders tables to show the details of who made these orders. 3. Boolean Operators can be used across columns. It is important to remember the difference between AND/OR operations. AND operations restrict your search. OR operations widen the search. You can combine AND/OR operations. The query below looks for orders that were made between two dates AND were made by customers from the UK OR France OR Canada. Page 8 of 19 04/07/12
  • 9. Your Task 1. Open the Query from the previous task 2. Make sure the Country field is included in the query. Add it if necessary. 3. Restrict the query to show only orders made by customers in Germany or Denmark or Austria. 4. Click the Design View button to make a further change to your search criteria. 5. Refine your query so that it shows orders made by customers in Germany or Denmark or Austria AND with the company name “Drachenblut Delikatessen” (the query should show only one order). 4. Using the OR operator in one column is easy but it becomes more complicated if. If you want to widen the search by adding an OR over several columns, you need to put the OR on a separate line. For example, this query shows orders made between two dates and all orders made by London companies: Your Task 1. In the example above, what would be the result if “London” were put in the Criteria row? 2. How good a salesperson is Nancy Davolio? Produce a query to show all orders that she took in 1994 that were over £50 in value. Page 9 of 19 04/07/12
  • 10. 8. Counting Queries To get your queries to do calculations, you start the query as normal, select the tables and fields you are going to use and then press the Sigma Button (∑) to make the Total Row appear. You need to have a field or fields to Group By. This function tells Access that you want to organise the information you are displaying into groups. You can group by several fields. You also need a field on which to perform a function The Count function simply tells you how many records are in each group. For example, the following query tells you how many customers are in each country: The following query will add together the daily value of UK orders, using the Sum function: Your Task 1. Using your Music database, do a query to count how many different artists you have in your database. 2. Using the Northwind database, calculate the total value of all orders made in 1996. Page 10 of 19 04/07/12
  • 11. You can use a Search Criteria in any field, including a Group By field. The following query, searches for products that cost more than $100 Access Functions and What They Do Group By Organises the query results Sum Adds up all the values in the field Avg Calculates the average values Min Returns the lowest value Max Returns the highest value Count Shows the number of records that match the query criteria First Returns the first value that Access finds Last Returns the last value that Access finds Expression Creates a calculated field Where Uses the field as part of the search criteria but does not display the field itself in the results of the query Your Task 1. Create a list of products that cost less than $50 2. Find the average price of Northwind’s products 3. Show the most expensive product only Page 11 of 19 04/07/12
  • 12. 9. Crosstab Queries Crosstab queries are used to summarise data in tables. It has a rows and columns format, where you can think of each row as a record and each column as a field describing that record. Unlike a table, however, there is an additional column that performs a calculation on the data. For example, you might create a crosstab query based on a table of sales orders. Products could be shown in rows and the Order Date in columns. You would also have a calculating column to Sum the values. The calculating column would provide a total value for each product. A crosstab query can be based on tables or queries. 1. You want to show the total value of the sales of each of Northwind’s products for each year. First, create a query that combines data from the Orders and Order Details tables. You need the name of the product, the dates on which the product was ordered and the value of each order. 2. Start the Crosstab Query Wizard. 3. Select the query that you just created. 4. You want to use the name of the product as the row heading. 5. Use the order date for the column headings. 6. Group the orders together by year. 7. The Wizard then asks you what number you want to be calculated at the intersection of each row and column. You want to add together the value of the orders. Page 12 of 19 04/07/12
  • 13. 10. Calculated Fields A calculated field takes numbers from other fields in the query and performs a calculation on them. You can add a calculated field to a query, as long as you include in the query all the data that the calculated field needs to perform its calculation. A calculated field can take data from more than one field. Calculated fields are ideal for performing “What if?” queries. For example, “what would our prices be if we increased all prices by 5%?” 1. To answer this question, use the Northwind database and create a new query using the Products Table. 2. You need the name of the product and the price of the product in the query. 3. Type [UnitPrice]*1.05 as the field name in a new field: 4. Run the query by clicking the Run Button. You will notice that your field name has been given the name Expr1, which isn’t very descriptive and the numbers in the column are not formatted as currency. Click the Design View button to remedy this. 5. Double click Expr1 to select it and change the name to New Price. 6. Click the Properties Button Change the Format of the field to Currency. In the Description Box type: Shows prices raised by 5%. Close the Properties. Page 13 of 19 04/07/12
  • 14. 7. Run the Query again and you will see the effect of your changes. When you click in the New Price field, you will see the Description Text appear in the Status Bar at the bottom-left of the Access window. Your Task The accounting department at Northwind want to know the value of each product that is on order. Produce a query with a calculated field that will show this. 8. Of course, the company could be awkward and reduce the prices by 4.5%, and then they might change their minds again. This needn’t be a worry to you if you make Access ask for a percentage value before running the calculation. To achieve this, simply make up the name of a field, for example “PercentIncrease” and include that in the expression in place of the figure. For example: New Price: [UnitPrice]*[Percent Increase] Now, when the query runs, it asks for a percentage increase and calculates the results accordingly. Your Task Northwind are considering reducing their prices for a month. Produce a query with a calculated field that will allow the accounting department to see the effect of a percentage decrease in the value of orders. 9. You can calculate with text fields as well as with numbers. A common use for this is when you want to combine the FirstName and LastName fields. You would simply enter: [FirstName]+" "+[LastName] N.B. the space between the quotation marks tells Access to leave a space between first name and last name. Your Task Create a list of customers with their titles in brackets. For example: Maria Anders (Sales Representative) Hint: Click the Build button on the toolbar to use the Expression Builder. Page 14 of 19 04/07/12
  • 15. 11. Other Types of Queries A Select Query is the commonest type of query. It answers questions about your data. An Action Query is a query that makes changes to your data. Simple jobs don't need complicated solutions. If you want to change every instance of a word or phrase, throughout a field, you can open a table, select a field and then select Replace from the Edit Menu (or use CRTL+H). In Find What: enter a word or phrase to search for. In Replace With: enter a word or phrase to replace it with. The other options in this dialog box are the same as for the Find feature. Your Task In the Customers Table of the Northwind Database change every example of the entry Owner to Proprietor. More complicated and widespread changes should be made with the appropriate type of Query. When you create a new query, Access gives you a Select Query. You can change the Query Type by opening the Query Menu and selecting a different type of query or you can use the Query Type drop-down list. You will recognise the Crosstab Query because you have used it before. The last four types of queries are listed with an exclamation mark to remind you that they actually change the way your information is organised. You should not run these queries unless you have first previewed the changes and unless you also have a backup. The Run button executes the query. All changes are saved automatically. The View button allows you to preview the query without saving the changes. Page 15 of 19 04/07/12
  • 16. 12. The Delete Query The delete query is the easiest type of action query to use and it is also the most dangerous! 1. Create a normal select query and add the fields you want. Preview the query when finished and click the View button to preview the changes. 2. Change the Query type from Select to Delete. You will notice that the Sort line changes to a Delete line. 3. Enter your criteria to delete. The following example, will remove records of customers located in France or Canada. 4. Click the View button and you will see a list of records that would be deleted if you were brave enough to click the Run button. If you are sure you want to delete these records, click the Design button and then click the Run button. Access will give you one last chance to change your mind and then your records will be trashed. Your Task In an act of blatant ageism, Northwind decide to sack all employees who were born before 1960. Create a Delete query that will remove these employees from the database. Preview the results but don't run the query. Page 16 of 19 04/07/12
  • 17. 13. The Update Query An update query allows you to create a query to select records and then change those records according to an instruction. 1. Create a select query first, preview it and then change the query type to Update Query. You will notice that the Sort line changes to an Update line. 2. Enter an instruction in the Update Line telling Access what to do with the records you have selected. This query will apply a 10% discount to all products over $100. 3. Clicking the View button will show you a list of the records that will be changed, should you decide to click the Run button. Your Task Increase the prices of all products in the Northwind Database that are over $50 by 10% 4. The other query types are less commonly used. Once you have got the hang of the Delete Query and the Update Query, these should not cause you too many problems: Make Table Query Saves the results of a query as an additional table. This is useful for exporting information to another database. Append Query Allows you to add information from a query to an existing table. In the Criteria line, you could, for example, append only those customers with unpaid bills. Find Duplicates From the results of a Find Duplicates query, you can Query determine if there are duplicate records in a table, or determine which records in a table share the same value. Use the Find Duplicates Query Wizard. Find Unmatched Using the Find Unmatched Query Wizard, you can find Query records in one table that don't have related records in another table. For example, you can find customers who don't have Page 17 of 19 04/07/12
  • 18. orders. Use the Find Unmatched Query Wizard. 14. Keyboard Shortcuts F2 Select an entire field Ctrl+; Insert the Current Date Ctrl+: Insert the Current Time Ctrl+Enter Insert a Line Break (use it in a memo or large text field) Ctrl++ Add New Record Ctrl+- Delete the Current Record Shift+Enter Save the Record Ctrl+Z Undo the last change you made (don't rely on this) Ctrl+Enter Open the selected object in Design View Alt+F4 Quit Access 15. Summary (from the Access Help file) Page 18 of 19 04/07/12
  • 19. Page 19 of 19 04/07/12