AIA101.3.Access Reports And Forms


Published on

3rd module in Accelerated Introduction to Microsoft Access. Covers reports, sub reports, forms. subforms, unbound forms, expression builder, wizards and designers.

Published in: Technology
  • Be the first to comment

AIA101.3.Access Reports And Forms

  1. 1. Microsoft Access Module - Reports and Forms P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 [email_address]
  2. 2. Module Outline <ul><li>Part 1: Reports </li></ul><ul><li>Part 2: Forms </li></ul>Two parts:
  3. 3. MS Access training Part 1 Creating Reports
  4. 4. Module Hands On <ul><ul><li>Create a summary report </li></ul></ul><ul><ul><li>Format the report </li></ul></ul><ul><ul><li>Add a calculated field </li></ul></ul><ul><ul><li>Add summary fields </li></ul></ul><ul><ul><li>Add conditional formatting </li></ul></ul><ul><ul><li>Sub-reports (optional) </li></ul></ul><ul><ul><ul><li>Create a sub-report </li></ul></ul></ul><ul><ul><ul><li>Create a master-detail report </li></ul></ul></ul><ul><li>Students “hands-on”: </li></ul>
  5. 5. Creating reports <ul><li>Two basic methods: </li></ul><ul><ul><li>Report Wizard </li></ul></ul><ul><ul><li>Report Designer </li></ul></ul><ul><li>Common approach is to start w/ the Wizard then modify the result </li></ul>
  6. 6. Report Wizard <ul><li>Building a Report by Using a Report Wizard </li></ul><ul><ul><li>Use the Report tab of the database window </li></ul></ul><ul><ul><li>Can base report on table or query </li></ul></ul><ul><ul><li>Report Wizard - a series of dialog boxes that steps you through the process of building a report </li></ul></ul>
  7. 8. Report Wizard <ul><li>After selecting the table or query you give the Wizard additional information… </li></ul><ul><ul><li>Grouping – for summaries, etc. </li></ul></ul><ul><ul><li>Sorting – for sort order within group, plus which summary function to use </li></ul></ul><ul><ul><li>Format and style </li></ul></ul>
  8. 9. Report Wizard <ul><li>Create a labor report </li></ul><ul><ul><li>Use qryLaborDetail query </li></ul></ul><ul><ul><li>Select wono, empno, fname, lname, hours </li></ul></ul><ul><ul><li>Group by wono </li></ul></ul><ul><ul><li>Use summary options: sum hours, </li></ul></ul><ul><ul><li>Layout and style to taste </li></ul></ul><ul><ul><li>Save as rptLabor </li></ul></ul>
  9. 10. Report Design Window <ul><li>Menu Bar and Toolbar Rulers - vertical and horizontal </li></ul><ul><li>Report Layout </li></ul><ul><li>Toolbox </li></ul><ul><li>Field List Box - used for adding fields to a report template </li></ul><ul><li>Properties Sheet or Section Detail Sheet - controls the appearance of a report object </li></ul><ul><li>Scroll Bars </li></ul>
  10. 11. Report Designer
  11. 12. Redesigning a Report <ul><li>Able to move field and title boxes around the design template via a drag operation </li></ul><ul><li>Able to resize the report bands using selection handles </li></ul><ul><li>Able to add additional titles using label control </li></ul><ul><li>Able to align text as well as change the font and size of type used </li></ul><ul><li>Can add background fill effects, etc. </li></ul>
  12. 13. Report Designer <ul><li>Open rptLabor in design view </li></ul><ul><ul><li>Format headings </li></ul></ul><ul><ul><li>Remove extra subtotal row and reduce band height </li></ul></ul><ul><ul><li>Fill title with grey background </li></ul></ul><ul><ul><li>Etc. </li></ul></ul><ul><ul><li>Save with same name (rptLabor) </li></ul></ul>
  13. 14. Report Designer Results
  14. 15. Report Designer <ul><li>Adding Fields </li></ul><ul><ul><li>Use toolbox, or </li></ul></ul><ul><ul><li>Drag and drop from field list </li></ul></ul><ul><ul><li>Set control source on property sheet if appropriate(see below) </li></ul></ul><ul><ul><li>Put SQL function around the control source for aggregate fields </li></ul></ul><ul><li>Two types </li></ul><ul><ul><li>Bound </li></ul></ul><ul><ul><li>Unbound (no control source) </li></ul></ul>
  15. 16. Report Designer Field List Function
  16. 17. Report Designer <ul><li>Open the report Labor in design view </li></ul><ul><ul><li>Add a cost column (unbound control) </li></ul></ul><ul><ul><li>Format to taste </li></ul></ul><ul><ul><li>Save report as rptLaborCost </li></ul></ul>
  17. 18. Report Designer <ul><li>One more change to Labor report </li></ul><ul><ul><li>Add group and grand totals to labor cost for the report </li></ul></ul><ul><ul><li>Add an unbound textbox control </li></ul></ul><ul><ul><li>Use a formula, =sum(…), as the control source </li></ul></ul><ul><ul><li>Save as rptLaborCost_2 </li></ul></ul>
  18. 19. Labor report with Cost Column
  19. 20. Conditional Formatting <ul><li>Format, Conditional Formatting commands from Menu Bar </li></ul><ul><li>Can be used for forms or reports </li></ul><ul><ul><li>Examines the contents of a field </li></ul></ul><ul><ul><li>Based upon field’s contents able to specify: </li></ul></ul><ul><ul><ul><li>Font/Font size/Font color </li></ul></ul></ul><ul><ul><ul><li>Background color </li></ul></ul></ul><ul><ul><ul><li>Text attributes (boldface, underline, italics) </li></ul></ul></ul><ul><li>Try flagging stdhrs >= 70 </li></ul>
  20. 21. Subreports <ul><li>Can have sub reports added to a main report </li></ul><ul><ul><li>to show detail </li></ul></ul><ul><ul><li>To add related information such as customer data on an invoice </li></ul></ul><ul><li>First create the sub report </li></ul><ul><li>Then create the main report and drag the sub report and drop it in place, or </li></ul><ul><li>Use the subform/sub-report control </li></ul>
  21. 23. Sub Reports <ul><li>Create a subreport named srptLaborDetail_3 </li></ul><ul><ul><li>Base on qryLaborDetail_3 </li></ul></ul><ul><ul><li>Be sure to use tabular format </li></ul></ul><ul><ul><li>Eliminate extraneous title information </li></ul></ul>
  22. 24. Labor Sub Report
  23. 25. Subreports <ul><li>Make sure you have a permanent link between work_orders and qryLaborDetail_3 </li></ul><ul><li>Create a main report rptWork_Orders_Main </li></ul><ul><ul><li>Base on work_orders table </li></ul></ul><ul><ul><li>Expand the detail band and drag the subreport srptLaborDetail_3 into position </li></ul></ul><ul><li>Format to taste </li></ul>
  24. 26. Sub Reports <ul><li>Drag new subreport to main report, or use sub/form subreport control </li></ul><ul><li>Save as rptWork_OrdersFull </li></ul>
  25. 27. Full Work Orders Report Results
  26. 28. Microsoft Access Training Part 2 Creating Forms
  27. 29. Module Hands On <ul><ul><li>Build two simple data entry forms </li></ul></ul><ul><ul><li>Create an unbound form </li></ul></ul><ul><ul><li>Create a sub-form </li></ul></ul><ul><ul><li>Build a master-detail form from above forms </li></ul></ul><ul><ul><li>Add totals </li></ul></ul><ul><li>Students “hands-on”: </li></ul>
  28. 30. Forms <ul><li>Form - provides for customized data entry instead of using the datasheet window </li></ul><ul><li>Also used to establish criteria for reports and queries </li></ul><ul><li>Found on the Forms tab of the database window </li></ul><ul><li>Form Wizards - a series of dialog boxes prompting you about your form requirements </li></ul>
  29. 31. Form Wizard <ul><li>Specify source table or query, fields, etc. (again, note fields can be bound or unbound) </li></ul><ul><li>Generally pick columnar style </li></ul><ul><li>Modify or preview result </li></ul><ul><li>Numerous properties can be set </li></ul><ul><ul><li>Format (Appearance, scroll bars, etc.) </li></ul></ul><ul><ul><li>Data (recordsource, etc.) </li></ul></ul><ul><ul><li>Event (These can call macros and program code) </li></ul></ul><ul><ul><li>Other </li></ul></ul>
  30. 33. Form Wizard (Instructor Led) <ul><li>Build a simple data entry form based on the employees table </li></ul><ul><ul><li>Modify the form when click finish </li></ul></ul><ul><ul><li>Set the caption property to “Maintain Employee Information” </li></ul></ul><ul><ul><li>Make text labels “semi-bold” </li></ul></ul><ul><ul><li>Size the form as desired </li></ul></ul><ul><ul><li>Set record selector to “NO” if desired </li></ul></ul><ul><ul><li>Save as frmEmployees </li></ul></ul>
  31. 34. Basic Employees form
  32. 35. Form Wizard (On your own) <ul><li>Build a simple data entry form based on the work_orders table </li></ul><ul><ul><li>Modify the form when click finish </li></ul></ul><ul><ul><li>Set the caption property to “Work Orders” </li></ul></ul><ul><ul><li>Make text labels “semi-bold” </li></ul></ul><ul><ul><li>Size the form as desired </li></ul></ul><ul><ul><li>Set record selector to “NO” if desired </li></ul></ul><ul><ul><li>Save as frmWork_Orders </li></ul></ul>
  33. 36. Basic Work Orders Form
  34. 37. Form Designer <ul><li>Design surface for forms </li></ul><ul><li>Add controls from toolbox </li></ul><ul><li>Some controls themselves have wizards which can invoke certain actions (run query, open report, etc) </li></ul>
  35. 39. Form Designer <ul><li>Build a criteria selection form for the parameter query qryParam (use design view) </li></ul><ul><ul><li>Add an unbound control named txtOrderNo </li></ul></ul><ul><ul><li>Make sure the control wizard button is depressed </li></ul></ul><ul><ul><li>Add a button which will run the param query </li></ul></ul><ul><ul><li>Run the form. What happened? Why? </li></ul></ul><ul><ul><li>Save as frmParam </li></ul></ul>
  36. 40. Fix the query and form then rerun Change the variable names to look at the form
  37. 41. Criteria Selection Form Results
  38. 42. Subforms <ul><li>Same idea as sub reports </li></ul><ul><li>Main form uses parent table; sub form uses child table </li></ul><ul><li>Several ways to create them </li></ul><ul><ul><li>Create sub form first, drag and drop to main form </li></ul></ul><ul><ul><li>Use subform/subreport control </li></ul></ul><ul><ul><li>Create with form wizard directly </li></ul></ul>
  39. 43. Subforms <ul><li>Same idea as sub reports </li></ul><ul><li>Main form uses parent table; sub form uses child table </li></ul><ul><li>Make sure you have a permanent link </li></ul><ul><li>Create sub form first, drag and drop to main form </li></ul><ul><li>Can also create with form wizard directly </li></ul>
  40. 44. Typical Subform
  41. 45. Subforms <ul><li>Create a subform named sfrmLaborDetail </li></ul><ul><ul><li>Use the form wizard </li></ul></ul><ul><ul><li>Base on qryLaborDetail_3 query </li></ul></ul><ul><ul><li>Pick tabular style (like a table or spreadsheet grid) </li></ul></ul>
  42. 46. Labor Detail Subform
  43. 47. Subforms <ul><li>Modify the frmWork_Orders form. It will be the new main form </li></ul><ul><ul><li>Drag and drop the sub form sfrmLaborDetail </li></ul></ul><ul><ul><li>Remove extraneous labels </li></ul></ul><ul><ul><li>Size and format as you like </li></ul></ul><ul><ul><li>Save as frmWork_OrdersDetail </li></ul></ul>
  44. 48. Placing a subform on a main form
  45. 49. Note link master and link child
  46. 50. Work Orders Detail Form
  47. 51. Sub Forms via the Wizard <ul><li>Sub Forms can also be built automatically </li></ul><ul><li>Select parent table fields </li></ul><ul><li>Then child table fields </li></ul><ul><li>The child table will go in the subform </li></ul>
  48. 52. Main and sub forms via Wizard (Instructor Demonstration)
  49. 53. Totals on Master-Detail Forms <ul><li>Common to add totals </li></ul><ul><ul><li>Total of invoice line items </li></ul></ul><ul><ul><li>Total of purchase order line items </li></ul></ul><ul><ul><li>Etc. </li></ul></ul><ul><li>Several ways </li></ul><ul><ul><li>Add a total field to the subform footer (simplest) </li></ul></ul><ul><ul><li>Add a total field to the main report using a domain aggregate </li></ul></ul><ul><ul><li>Add a total field to the main report using an SQL aggregate </li></ul></ul><ul><ul><li>Probably others! </li></ul></ul>
  50. 54. Adding a total to a sub form <ul><li>Works just like totals in reports </li></ul><ul><li>Add the total field in the footer </li></ul><ul><ul><li>Add the sum so that control source reads = sum([ fieldname ]) with the equals sign </li></ul></ul><ul><li>If desired can hide the footer field and add a field to the main form that references the total field on the subform </li></ul>
  51. 55. Add a total to a sub form <ul><li>Use the sfrmLaborDetail </li></ul><ul><li>Save as sfrmLaborDetail_Total </li></ul><ul><li>Expand the footer and add a field for hours </li></ul><ul><li>In the control source make sure expression is =sum([hours]) </li></ul><ul><li>Now add the sub form to the frmEmployees main form </li></ul>
  52. 56. Master-detail form with total
  53. 57. Domain Aggregates (Concept demonstration) <ul><li>Similar to Spreadsheet functions </li></ul><ul><li>Will total, etc., values in a field across several rows (records) </li></ul><ul><li>Can be used to populate a control on a form; say totals or counts of “columns” in a sub form </li></ul><ul><li>There are several: dlookup(), dsum(), dcount(), davg(), etc. </li></ul><ul><ul><li>Syntax: Dname(“fieldname”,”source”, “criteria”) </li></ul></ul><ul><ul><li>Note: quotes are mandatory </li></ul></ul>
  54. 58. Domain Aggregates Use builder to help build domain aggregates
  55. 59. Work Orders Form w/ Domain Aggregate
  56. 60. Microsoft Access End of Module P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472