1 / 30

Day 18: MICROSOFT ACCESS – CHAPTER 3 CONTD.

Day 18: MICROSOFT ACCESS – CHAPTER 3 CONTD. Akhila Kondai akhila.kondai@mail.wvu.edu October 21, 2014. Exercise. Go to the lecture notes page and Download Music_extended.accdb

Download Presentation

Day 18: MICROSOFT ACCESS – CHAPTER 3 CONTD.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Day 18:MICROSOFT ACCESS – CHAPTER 3 CONTD. AkhilaKondai akhila.kondai@mail.wvu.edu October 21, 2014

  2. Exercise • Go to the lecture notes page and Download Music_extended.accdb • Note the added records to complete the English band Def Leppard and also the addition of the Canadian band Rush…

  3. Exercise • Create a new query in design view • Add 3 tables: Bands, Countries, & Members…

  4. Specify an Exact Match Condition • An exact match condition only shows records that match your criteria in the “Criteria” row of the query design grid • The field values of the records for the field the criteria is specified in must match the condition exactly to be shown in the query results

  5. Exercise • Add the following fields from these tables: • [Bands] BandName • [Member] FirstName, LastName • [Countries] Country • Run the Query to see the unrestricted results of all the 16 records

  6. Adding Criteria • Return to Design View • In the criteria row for Country, type England to have it show us a Dynasetwith only band members from England • Rerun the query • Change England to Americaand rerun • Try Portugal to see that nothing returns!

  7. Using Comparison Operators… “And” / “Or” • When using multiple conditions for a query, you can use the logical operators to combine conditions • The “And” logical operator specifies that both conditions must be met • The “Or” logical operator specifies that one or the other of the conditions must be met

  8. Using “And” and “Or” • When you enter two conditions in the same row of the query design grid, an “And” condition is created • If you enter two conditions that are on separate rows, an “Or” condition is created

  9. Illustration of “And” & “Or” Logic

  10. Creating “And” Conditionin the Design Grid…

  11. Let’s Try an “And” • Clear any existing criteria • Add the field [Members] Living • Type England in the Country row and create the AND condition by placing Yes in the Living row to return all living band members from England • Run it • Go back and change Yes to No and rerun

  12. Let’s do an “Or” • Remove the old criteria • We will set the criteria to show all members from RushOR anyone from any band that is living at all from the list of members… • First lets put “Rush” in the [Bands] Name field and run to see the results

  13. Create the “OR” • We wish to not only see the members of Rush, but also in addition to them, anyone that might be alive in the members table. • In Design view, type “Yes” in the OR row for [Members] Living • You should now see a list of 10 additional records (13 total)

  14. Sorting Results by Data Type…

  15. Sort Exercise • Open the RockTrivia Query in Design View • In the Sort row for the BandName field, have it sort the records in Ascending Order • Run the Query

  16. Two-Level Sort • Leave the existing sort in place and move the last name field so that it is before the first name field in the Design view… • Click once to select it… let go and then click and drag to move it over • Add a secondary sort by having it do Last Name in Ascending order • Run it. Last names are now show alphabetically inside the band names

  17. We can also use “Wildcards”

  18. Wildcard Example We want to see all members whose last names begin with “E”… • Remove all existing sort options • In the last name field, type the letter E in Criteria and run the query. • (No results show as no one has just the letter E for a last name) • Make it read E*and rerun to get any other characters…

  19. Wildcards continued • Change the criteria to show people whose last names end in “N” • *N • Run it and we should see 7 records. • Remove all criteria.

  20. Using Fields without Showing • It is possible to use a field in searching but not show that field in the query results • Let’s say we want to see all band members whose bands begin and end in “d”, but not see the band name • Remove the “Show” row checkmark for BandName • Create the criteria and run !

  21. Operators Note: This technique is similar to what part of a query asks for in HW4 !

  22. Date Field Entries for Birthday • Note Born field in Members table is completed • Close Members table

  23. Criteria & Operators Exercise • Go to Design view for RockTrivia, add the Born field, and clear criteria, re-show BandName • In the criteria row for born, add: >1/1/1960 • Note we get 3 records • Try making it: >=1/1/1950 AND <=1/1/1960 • We get 9 Records • Change it to: <1/1/1960 • We get 13 records

  24. Calculations in a Query… • Mathematical calculation can be done as part of the query.. • We often do this for things that we do not need to store and take up space with • Expressions can be entered into the query design grid as if they were regular fields • Done on data type fields treated as numbers

  25. Calculations in a Query… • To perform a calculation in a query, you must created a calculated field in query design. • Make certain that you are following the rules of precedence !(Please Excuse My Dear Aunt Sally) • Two options for entering expressions: • Enter the expression directly into the field text box • Enter the expression in the Expression Builder

  26. Creating a Calculated Field • Remove the existing criteria • Click in the next available blank field where the name would be, and then click the magic wand “Builder” icon above • The expression builder shows up…

  27. The Expression Builder…

  28. Let’s make a Query to try this… • We want to figure out how many years they are alive. It would be inefficient to store this as we would have to update it all the time. • Build or type the following: • Age: (Date()-[Members]![Born])/365 Note: If you see <<expr>> be sure to remove it ! ! ! • Run it ! • Expand the width of the column if you see ####

  29. Changing Decimals Precision • Note: Similar to what is needed for to set decimal places on query results in homeworks!! YOU MUST RUN THE QUERY ONCE FIRST ! • In design view, right click Age field • Click Properties • Select Fixed for Format and 0 for Decimal Places • Re-run it to see it without the decimal places

  30. Questions ?

More Related