AIN100

491 views

Published on

2 day Microsoft Access class. Covers, tables, filters, queries, external data, froms, reports, action queries, macros and navigation forms.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
491
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

AIN100

  1. 1. Orange Coast Database Associates Course (800)355-9855 or http://ocdatabases.itgo.com AIN100 Introduction to Microsoft Access Orange Coast Database Associates Specializing in Microsoft Office, Access, SQL, and related technologies Classes custom designed for Working Professionals http://www.dhdursoassociates.com San Juan Capistrano, CA (800)355-9855Accelerated Computer Training for Working Professionals Factory 2010 Case
  2. 2. AIN100 - Introduction to Access Quick introduction to Access for experienced Windows users P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.dhdursoassociates.com slides.1@dhdursoassociates.com1 Factory AIN100 AIN100 - Introduction to Access  Introduction (s)  Facilities  Course Materials – Student Questionnaire – Syllabus – PowerPoint handouts for all sessions – Evaluation form – Training certificate2 AIN100 Factory
  3. 3. MS Access Introductory (100 Level) Curriculum AIN100 AIN100T Incl. A & B AIA101 AIN104 AIN102 AMP110 Reports Queries Macros & Forms3 AIN100 Factory AIN100 – Introduction to Access  Quick pace for experienced windows users  Assumes no prior knowledge of Access  End-user, not programmer, oriented  Somewhat structured towards personal use for analysis and reporting  Two levels – Day 1 (AIN100A) and Day 2 (AIN100B)4 AIN100 V1.2 Factory
  4. 4. AIN100 - Introduction to Access Course Topics:  Databases  Tables  External Data  Datasheet  Filters  Queries  Reports  Forms  Macros  Switchboards/Navigation Forms5 AIN100 Factory Introduction to Access Industry Standard Approach: Access has many ways to accomplish tasks. As an accelerated course we will cover only the most common. Tables Table Designer Queries Query designer Reports Wizard then modify Forms Wizard then modify Macros Macro Designer6 AIN100 Factory
  5. 5. AIN100 - Introduction to Access Course Format:  4 Sessions  Lecture  Demo  Student “hands-on” - by the end of the class the student will have constructed a small, functional application  Exercises are cumulative – later examples build on objects created earlier7 AIN100 Factory Database Design – Critical Topic  What do I want? – (Outputs)  What have I got? – (Inputs)  What do I need to do to get there? – (Process)8 AIN100 Factory
  6. 6. Note: we have a full day course (DBD201) on this important topic. Define Your Needs First  Draw a PRODUCTS picture  Write a ORDERS description C.C. EMPLOYEES Toys9 AIN100 Factory AIN100 - Introduction to Access Course Schedule (3 hour sessions):  Session 1 – Tables and Data  Session 2 – Filters – Queries  Session 3 – Reports – Forms  Session 4 – Forms (cont’d) – External Data – Automating Tasks10 AIN100 Factory
  7. 7. 11 AIN100 Factory
  8. 8. Introduction to Microsoft Access Module Introduction to Access, Tables, and Relationships P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com1 Factory Access Tables & Data Module Outline Three parts:  Topic 1: Introduction & Tables  Topic 2: Manipulating and sorting Tables  Topic 3: Relating Tables2 Access Tables & Data Factory
  9. 9. Module Hands On Students “hands-on”: – Create working folder with supplied files – Create a database – Create 3 tables (w/validation rules and masks) – Populate tables – Import and Export Tables – Create permanent links – Create a simple query – Compute calculated field(s) – Create a multi-table query with summary aggregates 3 Access Tables & Data Factory Introduction to Microsoft Access Part 1: Introduction to Access and Tables4 Factory Access Tables & Data
  10. 10. But first - Create Folder  Create a folder yourname (or similar) in My Documents – this is where your database and other files will go.  Optionally, copy in the labor.txt and employees.xls files from the instructor supplied location or CD.5 Access Tables & Data Factory Access Modes  Menu-driven interface - Interact with a database and its objects using menu commands  Program mode - Lets you store instructions in a VBA program file  This course concentrates on the menu interface but does cover macros which can be used to “program” a series of actions6 Access Tables & Data Factory
  11. 11. Database Terminology  Database – in Access a repository in which tables, reports, queries, and other objects are stored  Table – stores facts about one subject (entity)  Record - contains related information about an entity “instance”  Field - contains a fact about an entity  Relational Database - allows you to link records from two or more tables based on the contents of a common field. Access is a relational database.7 Access Tables & Data Factory Database Terminology (cont.)  Key - used to order, identify, and retrieve records in the database  Primary key - unique identifier for a particular record. Only one per table.  Index – like a book index. Speeds searches and joins. Can have many per table.  Table structure - the arrangement of information within a record, the type of characters, field length, limitations, etc.8 Access Tables & Data Factory
  12. 12. Database Terminology (cont.)  Object – used in database world as generic term for queries, reports, indexes, tables, etc. Not the same as programming object.  Form - paper-like method of accessing and entering data in a table  Query – retrieves information from Access tables  Report - provides the ability to arrange table data as well as to perform calculations and then print a paper-based report9 Access Tables & Data Factory Sample Application – Factory2000  Simple cost accounting application  Employees work on work orders  Clock labor hours for each work order10 Access Tables & Data Factory
  13. 13. Recording Factory2000 Labor Hours EmpNo fName lName Rate Wono Descr Hours 12 Bob Smith 15 A1 Casting 12 13 Mary Chavez 20 A1 Casting 22 14 Alicia Parks 25 B3 Ass’ly 15 14 Alicia Parks 25 C2 Screws 18 What problems do you see with this approach?11 Access Tables & Data FactoryFactory2000 Relational Database Structure EmpNo fName lName Rate MgrNo Wono Descr Std 12 Bob Smith 15 13 A1 Casting 30 13 Mary Chavez 20 B3 Fitting 50 14 Alicia Parks 25 12 C2 Screws 70 employees Work_orders EmpNo Wono Start End Hours 12 A1 1/1/01 1/31/01 20 14 C2 2/1/01 2/28/01 42 Labor 14 B3 1/1/01 2/28/01 4012 Access Tables & Data Factory
  14. 14. Creating a Database  Ways to create a database – Create a database using an Access template or Wizard – (not always recommended) – Create a blank database and then insert your own objects – we will use this method in this course13 Access Tables & Data Factory Creating an Access 2000 Database Create the database in your desktop folder with a meaningful name14 Access Tables & Data Factory
  15. 15. Creating a Table  Click new from tables tab  Naming a Table – Up to 64 “standard” characters can be used – Do not use an extension – No leading spaces or control characters, in fact try to avoid spaces altogether  Add fields one by one  Set Field Properties in Field Properties box15 Access Tables & Data Factory Designing Fields  Field Type – text, datetime, number, etc.  Field Width – 10 characters, etc.  Caption – “Column title” for display  Format – Determines how the field is displayed (long date, short date, etc.)  Click toolbar key symbol to make primary key  Set indexed for secondary keys, required, etc.16 Access Tables & Data Factory
  16. 16. Setting Properties in the Table Designer17 Access Tables & Data Factory Hands On - Create Tables  Employees  Work_Orders  Labor18 Access Tables & Data Factory
  17. 17. Employees Table Definition (Instructor led)  EmpNo text(2), primary key  Fname text(10)  Lname text (15), required  Rate currency, required  MgrNo text(2) All with captions19 Access Tables & Data Factory Work_Orders Table Definition (On your own)  WoNo text(2), primary key  Descr text(15)  StdHrs number(single,2), required  Accum number(single,2), required Add captions, too20 Access Tables & Data Factory
  18. 18. Labor Table Definition (On your own)  EmpNo text(2), primary key  WoNo text(2), primary key  Start datetime, required  End datetime  Hours number(single,2) Add captions, too21 Access Tables & Data Factory Field Validation & Masks  Add some validations – Test a numeric field for > 0 – Try checking one field against another – Etc.  Add captions if not added already  Add an input mask  Change a display format  Etc.22 Access Tables & Data Factory
  19. 19. Datasheets  Datasheet window - displays the contents of a table in a spreadsheet-like format – Each row contains a record – Each column contains a field  Speedbar - appears at the bottom of the window and is used to navigate through the records in a table23 Access Tables & Data Factory Datasheet View24 Access Tables & Data Factory
  20. 20. Entering & Editing Records  Enter table data from the handouts or use your own data25 Access Tables & Data Factory Employees Table Data26 Access Tables & Data Factory
  21. 21. Work_Orders Table Data27 Access Tables & Data Factory Labor Table Data28 Access Tables & Data Factory
  22. 22. Printing a Table  Access allows you to create “quick and dirty” reports by clicking the toolbar Print button – A row/column presentation is used – Field names appear along the top – Records are rows – Fields are columns – A grid is printed around each field29 Access Tables & Data Factory Quick Reports  Report Wizard – Module 2 covers reports – For now, be aware a quick report can be produced using auto report or a wizard30 Access Tables & Data Factory
  23. 23. Manipulating the Datasheet  Gridlines – controlled by Cells Effects dialog box  Can control background color, fonts, etc.  Fields can be resized and moved  Also, hidden and locked like a spreadsheet31 Record Pointer  Record pointer (thick black arrow head) helps you keep track of where you are in a table  The character is used in the left-hand table cells to indicate the pointer location  The pointer moves by using keyboard, scrollbar, or speedbar commands  => Changes are saved when you move to next record32
  24. 24. Find Command  Use the Edit | Find command sequence or click the Find toolbar button  Either command activates the Find in field dialog box  Searches can have “Wildcards” (in fact sophisticated Unix style searches are available)33 One Field Sort  Select the column to be used in the sort  Click the desired Sort Ascending or Descending toolbar button34
  25. 25. Multiple Field Sort  Filter - used to sort data or restrict records shown  Use Records | Filter | Advanced Filter/Sort command sequence  Activates the filter window  Specify the fields and sort order  Execute by clicking the Apply Filter/Sort button of the toolbar35 Introduction to Microsoft Access Topic 3 Relating Tables36 Factory Access Tables & Data
  26. 26. Relating Tables  Command sequence – Tools | Relationships  Parent table - table used as the main table for a relationship  Child table - the related table, often has several records for each record in the parent table37 Access Tables & Data Factory Referential Integrity  Referential integrity - makes certain that related records are present  Orphan record - a child record without a corresponding parent record38 Access Tables & Data Factory
  27. 27. Table Links  In this context means relate two or more tables on columns of data  Permanent link – – established using the Relationships command – is always in effect once defined  Transient link - defined using the query-by- example feature of Access39 Access Tables & Data Factory Creating a Permanent Link Drag from PK to FK40 Access Tables & Data Factory
  28. 28. Create Permanent Links Link all Factory2000 tables Enforce referential integrity Normal, default joins for now41 Access Tables & Data Factory Permanent Links42 Access Tables & Data Factory
  29. 29. Introduction to Microsoft Access End of Module P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com43 Factory Access Tables & Data44
  30. 30. Microsoft Access Module: Filters1 Multi-case Access - Filters Module Hands On Students “hands-on”: – Create a filter 2 Access - Filters Multi-case
  31. 31. Datasheets and Filters  Datasheet window - displays the contents of a table in a spreadsheet-like format – Each row contains a record – Each column contains a field  Filters – Datasheet can have a filter to show only records that meet a given criteria – Filters can be saved like a query3 Access - Filters Multi-case Employees Table before Filter4 Access - Filters Multi-case
  32. 32. Filtering a Table  Use the filter to display records that meet certain criteria  Enter criteria in the filter cells  Execute by clicking the Apply Filter/Sort button of the toolbar – Filter By Form – Filter By Selection5 Access - Filters Multi-case Filter Buttons6 Access - Filters Multi-case
  33. 33. Create a Filter on Employees Table  Rate over 15  Sort by last name  Save as fltEmployeeRate7 Access - Filters Multi-case Filter Design8 Access - Filters Multi-case
  34. 34. Filter Results9 Access - Filters Multi-case Microsoft Access End of Module P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com10 Multi-case Access - Filters
  35. 35. 11 Access - Filters Multi-case
  36. 36. Microsoft Access Module: Queries P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com1 Factory Access - Accelerated Queries Module Hands On Students “hands-on”: – Create a simple query – Create a multi-table query – Create calculated fields – Create a summary query – Concatenate fields – Create a parameter query2 Access - Accelerated Queries Factory
  37. 37. Creating a Query  Activate the Create tab of the Database window  Click the Query Design button  Interact with the dialog boxes3 Access - Accelerated Queries Factory Query Results  Results placed in a dynaset in a window  Dynaset can be used like a regular table – Most useful when you work with fields from several tables – Any changes that are made to a dynaset field are also made to the original record4 Access - Accelerated Queries Factory
  38. 38. Query Design Window  QBE grid - controls which fields appear in the dynaset  Parts of the grid – Field - contains the name of the field – Table - contains the field’s table name – Sort - controls the order of displayed data – Show - displays a field in the dynaset – Criteria - enter a condition to display selected records5 Access - Accelerated Queries Factory Criteria  Logical Comparison Operators – <, >, =, =<, >=. <>  Special Operators – LIKE – IS NULL – BETWEEN – IN  Special characters – [ square brackets around names] – (parentheses around function arguments) – # pound sign around dates#6 Access - Accelerated Queries Factory
  39. 39. Like (“Wild Card Matches”)  ANSI standard  Microsoft Access  Where  Where customer_last_name like customer_last_name like “Jo%” “Jo*”  Like “Jo_”  Like “Jo?” • * means match any string of characters; ? means match one character. • Access actually allow more sophisticated Unix type search patterns as well – see help7 Access - Accelerated Queries Factory Create a Simple Query  Use Work_Orders table  Show fields: all except accum  Sort by WoNo  Only records where description contains an “s”  Save your query as qrySimple8 Access - Accelerated Queries Factory
  40. 40. Simple Query (Find all records with an “S in the description field) Query by Example (QBE) Grid9 Access - Accelerated Queries Factory Joining Tables  Tables can be joined for performing a query – Must have a common field – Linking in QBE grid performed via a drag operation – Join types: inner, left outer, right outer – Use show tables dialog to bring up list of tables10 Access - Accelerated Queries Factory
  41. 41. Joining two Tables Drag from PK to FK Double Click table name to add11 Access - Accelerated Queries Factory Create a multi-table query  Join Labor and Employees  Show following fields: all from labor, fname, lname and rate from employees  Sort by empno then wono  Save your query as qryLaborDetail12 Access - Accelerated Queries Factory
  42. 42. Multi-table Query Design13 Access - Accelerated Queries Factory Multi-table Query Results14 Access - Accelerated Queries Factory
  43. 43. Calculated Fields  Can embed calculations in a query  Creates a new temporary field which appears in the dynaset  Store your calculations there  Can use an expression “builder” to help15 Access - Accelerated Queries Factory Query with Calculated Field (use the builder)16 Access - Accelerated Queries Factory
  44. 44. Query with Calculated Field  Use qryLaborDetail  Add a calculated field which shows the cost of a labor ticket  Save your query as qryLaborDetail_217 Access - Accelerated Queries Factory Query with Calculated Field Results18 Access - Accelerated Queries Factory
  45. 45. Concatenated Fields  Can “add” two character fields together  Use & operator  Example: fname & “ “ & lname19 Access - Accelerated Queries Factory Concatenated Fields  Create a new labordetail query  Add a column with the employee’s full name  This can be used later in reports, etc.  Save your query as qryLaborDetail_320 Access - Accelerated Queries Factory
  46. 46. Concatenated Fields Results21 Access - Accelerated Queries Factory Summarizing Columns  SQL aggregate functions – Sum – Count – Avg – Etc.  Activated by clicking the Total toolbar button  Adds a Total line to the QBE query grid  All selected columns must be in group by or an aggregate22 Access - Accelerated Queries Factory
  47. 47. Query with Aggregate23 Access - Accelerated Queries Factory Query with Aggregate  Modify qryLaborDetail2  Drop work order fields  Sum the hours and cost  Save your query as qryLaborGrouped24 Access - Accelerated Queries Factory
  48. 48. Query with Aggregate Results25 Access - Accelerated Queries Factory Parameter Queries  Accept a variable when run Order No parameter26 Access - Accelerated Queries Factory
  49. 49. Parameter Queries  Create a parameter query  Base on qryLaborDetail_3  Show all fields  Prompt for order no  Save as qryParam27 Access - Accelerated Queries Factory Parameter Query Results28 Access - Accelerated Queries Factory
  50. 50. Accelerated Introduction to Access End of Module P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com29 Factory Access - Accelerated Queries30 Access - Accelerated Queries Factory
  51. 51. 31 Access - Accelerated Queries Factory
  52. 52. Microsoft Access Module - Reports P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com1 Factory Access - Reports & Forms Module Hands On Students “hands-on”: Day 1 – Part 1  Create a summary report  Format the report  Add conditional formatting – Part 2  Add a calculated field  Add summary fields – Sub-reports (optional)  Create a sub-report  Create a master-detail report2 Access - Reports & Forms Factory
  53. 53. Creating reports  Two basic methods: – Report Wizard – Report Designer  Common approach is to start w/ the Wizard then modify the result3 Access - Reports & Forms Factory Report Wizard  Building a Report by Using a Report Wizard – Use the Report tab of the database window – Can base report on table or query – Report Wizard - a series of dialog boxes that steps you through the process of building a report4 Access - Reports & Forms Factory
  54. 54. 5 Access - Reports & Forms Factory Report Wizard  After selecting the table or query you give the Wizard additional information… – Grouping – for summaries, etc. – Sorting – for sort order within group, plus which summary function to use – Format and style6 Access - Reports & Forms Factory
  55. 55. Report Wizard  Create a labor report – Use qryLaborDetail query – Select wono, empno, fname, lname, hours – Group by wono – Use summary options: sum hours, – Layout and style to taste – Save as rptLabor7 Access - Reports & Forms Factory Report Design Window  Menu Bar and Toolbar Rulers - vertical and horizontal  Report Layout  Toolbox  Field List Box - used for adding fields to a report template  Properties Sheet or Section Detail Sheet - controls the appearance of a report object  Scroll Bars8 Access - Reports & Forms Factory
  56. 56. Report Designer9 Access - Reports & Forms Factory Redesigning a Report  Able to move field and title boxes around the design template via a drag operation  Able to resize the report bands using selection handles  Able to add additional titles using label control  Able to align text as well as change the font and size of type used  Can add background fill effects, etc.10 Access - Reports & Forms Factory
  57. 57. Report Designer  Open rptLabor in design view – Format headings – Remove extra subtotal row and reduce band height – Fill title with grey background – Etc. – Save with same name (rptLabor)11 Access - Reports & Forms Factory Report Designer Results12 Access - Reports & Forms Factory
  58. 58. Report Designer  Adding Fields – Use toolbox, or – Drag and drop from field list – Set control source on property sheet if appropriate(see below) – Put SQL function around the control source for aggregate fields  Two types – Bound – Unbound (no control source)13 Access - Reports & Forms Factory Report Designer Function14 Access - Reports & Forms Factory
  59. 59. Report Designer  Open the report Labor in design view – Add a cost column (unbound control) – Format to taste – Save report as rptLaborCost15 Access - Reports & Forms Factory Report Designer  One more change to Labor report – Add group and grand totals to labor cost for the report – Add an unbound textbox control – Use a formula, =sum(…), as the control source – Save as rptLaborCost_216 Access - Reports & Forms Factory
  60. 60. Labor report with Cost Column17 Access - Reports & Forms Factory Conditional Formatting  Format, Conditional Formatting commands from Menu Bar  Can be used for forms or reports – Examines the contents of a field – Based upon field’s contents able to specify:  Font/Font size/Font color  Background color  Text attributes (boldface, underline, italics)  Try flagging stdhrs >= 7018 Access - Reports & Forms Factory
  61. 61. Subreports  Can have sub reports added to a main report – to show detail – To add related information such as customer data on an invoice  First create the sub report  Then create the main report and drag the sub report and drop it in place, or  Use the subform/sub-report control19 Access - Reports & Forms Factory20 Access - Reports & Forms Factory
  62. 62. Sub Reports  Create a subreport named srptLaborDetail_3 – Base on qryLaborDetail_3 – Be sure to use tabular format – Eliminate extraneous title information21 Access - Reports & Forms Factory Labor Sub Report22 Access - Reports & Forms Factory
  63. 63. Subreports  Make sure you have a permanent link between work_orders and qryLaborDetail_3  Create a main report rptWork_Orders_Main – Base on work_orders table – Expand the detail band and drag the subreport srptLaborDetail_3 into position  Format to taste23 Access - Reports & Forms Factory Sub Reports  Drag new subreport to main report, or use sub/form subreport control  Save as rptWork_OrdersFull24 Access - Reports & Forms Factory
  64. 64. Full Work Orders Report Results25 Access - Reports & Forms Factory Microsoft Access Module - Reports P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 [End of Module] http://www.d2associates.com26 Factory Access - Reports & Forms
  65. 65. 27 Access - Reports & Forms Factory
  66. 66. Introduction to Microsoft Access Module - Forms P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com1 Factory Access - Reports & Forms Module Hands On Students “hands-on”: – Part 1  Build two simple data entry forms – Part 2  Create an unbound form  Create a sub-form  Build a master-detail form using above sub-form  Add totals2 Access - Reports & Forms Factory
  67. 67. Forms  Form - provides for customized data entry instead of using the datasheet window  Also used to establish criteria for reports and queries  Found on the Forms tab of the database window  Form Wizards - a series of dialog boxes prompting you about your form requirements3 Access - Reports & Forms Factory Form Wizard  Specify source table or query, fields, etc. (again, note fields can be bound or unbound)  Generally pick columnar style  Modify or preview result  Numerous properties can be set – Format (Appearance, scroll bars, etc.) – Data (recordsource, etc.) – Event (These can call macros and program code) – Other4 Access - Reports & Forms Factory
  68. 68. 5 Access - Reports & Forms Factory Form Wizard (Instructor Led)  Build a simple data entry form based on the employees table – Modify the form when click finish – Set the caption property to “Maintain Employee Information” – Make text labels “semi-bold” – Size the form as desired – Set record selector to “NO” if desired – Save as frmEmployees6 Access - Reports & Forms Factory
  69. 69. Basic Employees form7 Access - Reports & Forms Factory Form Wizard (On your own)  Build a simple data entry form based on the work_orders table – Modify the form when click finish – Set the caption property to “Work Orders” – Make text labels “semi-bold” – Size the form as desired – Set record selector to “NO” if desired – Save as frmWork_Orders8 Access - Reports & Forms Factory
  70. 70. Basic Work Orders Form9 Access - Reports & Forms Factory Form Designer  Design surface for forms  Add controls from toolbox  Some controls themselves have wizards which can invoke certain actions (run query, open report, etc)10 Access - Reports & Forms Factory
  71. 71. 11 Access - Reports & Forms Factory Form Designer  Build a criteria selection form for the parameter query qryParam (use design view) – Add an unbound control named txtOrderNo – Make sure the control wizard button is depressed – Add a button which will run the param query – Run the form. What happened? Why? – Save as frmParam12 Access - Reports & Forms Factory
  72. 72. Fix the query and form then rerun Change the variable names to look at the form13 Access - Reports & Forms Factory Criteria Selection Form Results14 Access - Reports & Forms Factory
  73. 73. Subforms  Same idea as sub reports  Main form uses parent table; sub form uses child table  Several ways to create them – Create sub form first, drag and drop to main form – Use subform/subreport control – Create with form wizard directly15 Access - Reports & Forms Factory Subforms  Same idea as sub reports  Main form uses parent table; sub form uses child table  Make sure you have a permanent link  Create sub form first, drag and drop to main form  Can also create with form wizard directly16 Access - Reports & Forms Factory
  74. 74. Typical Subform17 Access - Reports & Forms Factory Subforms  Create a subform named sfrmLaborDetail – Use the form wizard – Base on qryLaborDetail_3 query – Pick tabular style (like a table or spreadsheet grid)18 Access - Reports & Forms Factory
  75. 75. Labor Detail Subform19 Access - Reports & Forms Factory Subforms  Modify the frmWork_Orders form. It will be the new main form – Drag and drop the sub form sfrmLaborDetail – Remove extraneous labels – Size and format as you like – Save as frmWork_OrdersDetail20 Access - Reports & Forms Factory
  76. 76. Placing a subform on a main form21 Access - Reports & Forms Factory Note link master and link child22 Access - Reports & Forms Factory
  77. 77. Work Orders Detail Form23 Access - Reports & Forms Factory Sub Forms via the Wizard  Sub Forms can also be built automatically  Select parent table fields  Then child table fields  The child table will go in the subform24 Access - Reports & Forms Factory
  78. 78. Main and sub forms via Wizard (Instructor Demonstration)25 Access - Reports & Forms Factory Totals on Master-Detail Forms  Common to add totals – Total of invoice line items – Total of purchase order line items – Etc.  Several ways – Add a total field to the subform footer (simplest) – Add a total field to the main report using a domain aggregate – Add a total field to the main report using an SQL aggregate – Probably others!26 Access - Reports & Forms Factory
  79. 79. Adding a total to a sub form  Works just like totals in reports  Add the total field in the footer – Add the sum so that control source reads = sum([fieldname]) with the equals sign  If desired can hide the footer field and add a field to the main form that references the total field on the subform27 Access - Reports & Forms Factory Add a total to a sub form  Use the sfrmLaborDetail  Save as sfrmLaborDetail_Total  Expand the footer and add a field for hours  In the control source make sure expression is =sum([hours])  Now add the sub form to the frmEmployees main form28 Access - Reports & Forms Factory
  80. 80. Master-detail form with total29 Access - Reports & Forms Factory Domain Aggregates (Concept demonstration)  Similar to Spreadsheet functions  Will total, etc., values in a field across several rows (records)  Can be used to populate a control on a form; say totals or counts of “columns” in a sub form  There are several: dlookup(), dsum(), dcount(), davg(), etc. – Syntax: Dname(“fieldname”,”source”, “criteria”) – Note: quotes are mandatory30 Access - Reports & Forms Factory
  81. 81. Domain Aggregates Use builder to help build domain aggregates31 Access - Reports & Forms Factory Work Orders Form w/ Domain Aggregate32 Access - Reports & Forms Factory
  82. 82. Introduction to Microsoft Access Module - Forms P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 [End of Module] http://www.d2associates.com33 Factory Access - Reports & Forms34 Access - Reports & Forms Factory
  83. 83. 35 Access - Reports & Forms Factory
  84. 84. Introduction to Access Module Introduction to Access, External Data P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com1 Factory Access Accel. Introduction v1.02 Module Outline Three short topics:  Topic 1: Export tables  Topic 2: Import data  Topic 3: Link tables2 Access Accel. Introduction v1.02 Factory
  85. 85. Module Hands On Students “hands-on”: – Export work_orders and employees tables – Import work_orders text file – Link employees excel file3 Access Accel. Introduction v1.02 Factory Sample Application – Factory2000  Simple cost accounting application  Employees work on work orders  Clock labor hours for each work order4 Access Accel. Introduction v1.02 Factory
  86. 86. Recording Factory2000 Labor Hours EmpNo fName lName Rate Wono Descr Hours 12 Bob Smith 15 A1 Casting 12 13 Mary Chavez 20 A1 Casting 22 14 Alicia Parks 25 B3 Ass’ly 15 14 Alicia Parks 25 C2 Screws 18 What problems do you see with this approach?5 Access Accel. Introduction v1.02 FactoryFactory2000 Relational Database Structure EmpNo fName lName Rate MgrNo Wono Descr Std 12 Bob Smith 15 13 A1 Casting 30 13 Mary Chavez 20 B3 Fitting 50 14 Alicia Parks 25 12 C2 Screws 70 employees Work_orders EmpNo Wono Start End Hours 12 A1 1/1/01 1/31/01 20 14 C2 2/1/01 2/28/01 42 Labor 14 B3 1/1/01 2/28/01 406 Access Accel. Introduction v1.02 Factory
  87. 87. Exporting a table  Very simple  Click File|Export (or save as)  Specify type: Access can export to many types: Excel, Text, etc.7 Access Accel. Introduction v1.02 Factory Exporting tables  Export Work_Orders to CSV text file.  Export Employees to an Excel spreadsheet.  Note you can also export to another Access table. Even one elsewhere on a LAN!8 Access Accel. Introduction v1.02 Factory
  88. 88. Using External Data  Two methods: – Import the data into a new (or existing table) in your database – Link to the data. A table link appears in your database but the data stays in the original file.9 Access Accel. Introduction v1.02 Factory Importing Files  Another very important feature  Start from new table dialog, pick Import Table  It will start a wizard  Use advanced to select fields, etc.  Specifications can be saved for later use10 Access Accel. Introduction v1.02 Factory
  89. 89. Importing a Text File Importing a table from a Text File11 Access Accel. Introduction v1.02 Factory Importing from a text file  Import the instructor-supplied labor text file into the previously created labor table  Save the specification12 Access Accel. Introduction v1.02 Factory
  90. 90. Linking a table  Use new table dialog  Select Link Table  This will set up a connection to an external table. It does not become part of the Access database  Access can link to many types: Excel, ODBC connection, etc.13 Access Accel. Introduction v1.02 Factory Linking a Table Linking a table14 Access Accel. Introduction v1.02 Factory
  91. 91. Linking a Table Linking a table15 Access Accel. Introduction v1.02 Factory Linking a Table Linking a table16 Access Accel. Introduction v1.02 Factory
  92. 92. Link a table  Link the Employees Excel  Give it a name like Employees_xls17 Access Accel. Introduction v1.02 Factory Introduction to Microsoft Access Module Introduction to Access, External Data P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com [End of Module]18 Factory Access Accel. Introduction v1.02
  93. 93. 19
  94. 94. Microsoft Access Module - Automating the Application - Advanced Queries, Macros, Control Wizards P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.dhdursoassociates.com1 Factory Access - Automating Tasks Module Outline Three parts:  Part 1: Advanced Queries  Part 2: Macros  Part 3: Control Wizards2 Access - Automating Tasks Factory
  95. 95. Module Hands On Students “hands-on”: – Create action queries  Maketable  Append  Delete – Create macros  Simple  Run from form  Add where criteria  Add a condition – Use the control wizard to close a form3 Access - Automating Tasks Factory MS Access Training Part 1 Advanced Queries4 Access - Automating Tasks Factory
  96. 96. Advanced Queries  Several types of special-use queries – Action  Make table*  Append*  Delete*  Update – Other  Pass-through, crosstab etc.  We will cover those with an *; others as time and interest permit  Reached through Query menu bar when query designer is open5 Access - Automating Tasks Factory6 Access - Automating Tasks Factory
  97. 97. MakeTable Query  Allows you to create a new table based on a query  Can be output to current database or another one  Very simple – Design your query as you normally would – Pull down the query menu and select make table. Assign the new table name7 Access - Automating Tasks Factory MakeTable Query  Create an extract of the Employees table – Save table as Temp_Employees – Select MgrNo = 13 – Save your query as qryMake_Temp_Employees8 Access - Automating Tasks Factory
  98. 98. MakeTable Query Results9 Access - Automating Tasks Factory Append Query  Appends records to an existing table  Design query then pull down query menu and select table to append to  Must indicate destination field for each source field in query. This is done in a new QBE grid row.  Can have additional “criteria” fields with no destination10 Access - Automating Tasks Factory
  99. 99. 11 Access - Automating Tasks Factory Append Query  Create and execute an append query  Select from Employees all records with MgrNo =12  Append to table Temp_Employees  Save the query as qryAppend_Temp_Employees12 Access - Automating Tasks Factory
  100. 100. Append Query Results13 Access - Automating Tasks Factory Delete Query  Deletes records from an existing table  Go to query design window then pull down query menu and select table to delete from  Establish the criteria in the criteria row14 Access - Automating Tasks Factory
  101. 101. Delete Query  Delete from temp_employees – All records with rate less than 2015 Access - Automating Tasks Factory Delete Query Results16 Access - Automating Tasks Factory
  102. 102. Other Advanced Queries  Union – “Adds” results of two queries into one result  Update – Update records in an existing table  SQL Pass-through – Send an SQL statement directly to “back-end” database (Oracle, DB2, etc.)  Crosstab – Creates a crosstab result (similar to a spreadsheet)  Etc.17 Access - Automating Tasks Factory Microsoft Access Part 2 Introduction to Macros18 Factory Access - Automating Tasks
  103. 103. Introduction to Macros  Two ways of “programming” a task in Access – Macros – Visual Basic for Applications (VBA)  We will cover Macros primarily  We will also take a look at control wizards which do use VBA19 Access - Automating Tasks Factory Introduction to Macros  Three types of macros – Standalone  Appear in the navigation pane – Embedded  Embedded in forms and reports – Data macro  Stored with a table20 Access - Automating Tasks Factory
  104. 104. Introduction to Macros  Elements of Macros – Events – what “fires” the macro – Actions – what the macro does – Action arguments – control the specifics of the action – Conditions – circumstance under which the macro “fires”  Macro designer – Where macro is defined21 Access - Automating Tasks Factory22 Access - Automating Tasks Factory
  105. 105. Introduction to Macros  Create and run a simple macro, mcrFirst, to become familiar with the concepts – Action = msgbox – Arguments:  “Hello, Macro”  information type  title = “My First Macro”23 Access - Automating Tasks Factory Designing the First Macro24 Access - Automating Tasks Factory
  106. 106. My First Macro25 Access - Automating Tasks Factory Automating Import/Export with Macros  Can string together several macros one after the other  Useful to do an import (or links, even) followed by data manipulation  As an example we will automate our prior three action queries26 Access - Automating Tasks Factory
  107. 107. Import Macro  Design a simple macro to import a table  Action is transfertext  Arguments are labor text file to be imported  Save as mcrImport27 Access - Automating Tasks Factory Designing Import Macro28 Access - Automating Tasks Factory
  108. 108. Macro “Programs”  Create a new macro to run the action queries created earlier  Use open query action  Use the action query name as the argument  Add a msgbox  Open the import table when done  Save as mcrActionQueries29 Access - Automating Tasks Factory More on Macros  Macros can be invoked depending on “condition”  Uses a condition column  Macro will run iff condition is true  Macros can be run one after another like a “program”. Example: – Do a maketable query , then an append query from a different file. I.E different downloads from an ERP system30 Access - Automating Tasks Factory
  109. 109. MS Access Training Part 3 Control Wizards31 Access - Automating Tasks Factory Control Wizards  Will create program code for you to perform a task  Form operations  Report operations  Etc.  Invoked by making sure the wizard button is depressed when adding a control32 Access - Automating Tasks Factory
  110. 110. Using the Control Wizard Reached from more option…33 Access - Automating Tasks Factory Using the Control Wizard34 Access - Automating Tasks Factory
  111. 111. Form Events  Forms and controls have “events”  These “fire” on certain actions. Examples: – Click a button (onclick event) – Before table is updated (beforeupdate event) – After table is updated (afterupdate event) – Etc.35 Access - Automating Tasks Factory Form Events (cont’d)  When an event “fires” can execute: – VBA Code – Macro  This provides a method for “running” an application36 Access - Automating Tasks Factory
  112. 112. Control wizards  Create a criteria selection form  Add a button to run the action queries  Add a button to close the form  Run the form  That’s it!37 Access - Automating Tasks Factory Form with Button to Launch Macro38 Access - Automating Tasks Factory
  113. 113. Microsoft Access End of Module P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com39 Factory Access - Automating Tasks40 Access - Automating Tasks Factory
  114. 114. Microsoft Access Module – Navigation P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com1 Factory Access Navigation Access navigation  Newer Access 2010 databases use the new Navigation forms  Older MDB databases still have the Switchboard Manager tool available2 Access Navigation Factory
  115. 115. Creating a Navigation form  Select the desired style3 Access Navigation Factory Navigation Forms  Drag and drop forms and reports one by one4 Access Navigation Factory
  116. 116. Adjust properties  Adjust properties as desired and save as frmNavigation5 Access Navigation Factory Set startup options (File | Options)  Set the Access options to open the navigation form when it starts up6 Access Navigation Factory
  117. 117. Navigation Form  Create a navigation form for your application7 Access Navigation Factory Switchboards  Create via a switchboard manager tool  Creates a tree of launch forms – main form is called switchboard and is placed with your other form objects8 Access Navigation Factory
  118. 118. Launching Switchboard Manager9 Access Navigation Factory Switchboard Manager  Yes – we want to create a new switchboard!10 Access Navigation Factory
  119. 119. Switchboard Manager11 Access Navigation Factory Switchboards  Create a switchboard for your application12 Access Navigation Factory
  120. 120. Microsoft Access End of Module P.O. Box 6142 Laguna Niguel, CA 92607 Please fill out and turn in your 949-489-1472 end-of-course evaluations. http://www.d2associates.com13 Factory Access Navigation14 Access Navigation Factory
  121. 121. 15 Access Navigation Factory
  122. 122. Orange Coast Database Associates Course (800)355-9855 or http://ocdatabases.itgo.com Accelerated Computer Training Orange Coast Database Associates Specializing in Microsoft Office, Access, SQL, and related technologies Computer Training, Programming & Consulting 32422 Alipaz St., Suite A-15 San Juan Capistrano, CA (800)355-9855 (Toll Free) | (949)489-1472 (Direct) | (949)485-6284 (Fax) http://www.dhdursoassociates.com | sales@dhdursoassociates.comAccelerated Computer Training for Working Professionals

×