Microsoft Access 2013 ®® Tutorial 10 Automating Tasks with Macros
XP Objectives Session 10.1 – Run and add actions to macros – Single step a macro – Create a submacro – Add a command button to a form – Attach a macro to a command Button New Perspectives on Microsoft Access 20132
XP Objectives Session 10.2 – Create an unbound form – Add a list box to a form – Use a SQL statement to fill a list box with object names – Create multiple macros for a form – Create a navigation form New Perspectives on Microsoft Access 20133
XP Creating a User Interface Case - Chatham Community Health Services Creating a User Interface for the Health Database User would like to implement a user interface for the Health database. For less experienced users, he would like the interface will display specific forms and reports, and all the queries in the database, so that users can select objects they want to work with from the interface For more advanced users, a form that has some buttons that users can click to perform common tasks will be created New Perspectives on Microsoft Access 20134
XP Creating a User Interface (Cont.) New Perspectives on Microsoft Access 20135
XP New Perspectives on Microsoft Access Creating a User Interface (Cont.)
XP New Perspectives on Microsoft Access Introduction to Macros
XP New Perspectives on Microsoft Access Running a Macro
XP Running a Macro (Cont.) New Perspectives on Microsoft Access 20139
XP Adding Actions to a Macro New Perspectives on Microsoft Access Arguments – A piece of data that is required by an action – MessageBox Four arguments: The Message argument contains text that appears in the message box when it is displayed The Beep argument (Yes or No), specifies whether a beep will sound when the message box opens The Type argument determines which icon, if any, appears Choices are None, Critical Warning? Warning! and Information The Title argument contains the word(s) that will appear in the message box title
XP Adding Actions to a Macro (Cont.) New Perspectives on Microsoft Access
XP Adding Actions to a Macro (Cont.) New Perspectives on Microsoft Access
XP Adding Actions to a Macro (Cont.) New Perspectives on Microsoft Access
XP Single Stepping a Macro New Perspectives on Microsoft Access Single Step Mode – Executes a macro one action at a time, pausing between actions – called single stepping – Allows you to make sure you have placed actions in the right order and with the correct arguments – You can use single step mode to find the causes of problems and to determine corrections – The Single Step button on the DESIGN tab is a toggle you use to turn single step mode on and off Once you turn on single step mode, it stays on for all macros until you turn it off
XP Single Stepping a Macro (Cont.) New Perspectives on Microsoft Access
XP Using a Command Button with an Attached Macro New Perspectives on Microsoft Access
XP Using a Command Button with an Attached Macro (Cont.) New Perspectives on Microsoft Access Event – A state, condition, or occurrence detectable by Access Event Property – Specifies how an object responds when an event occurs Event Procedure – A group of statements using VBA code that Access executes together
XP Using a Command Button with an Attached Macro (Cont.) New Perspectives on Microsoft Access
XP Submacros New Perspectives on Microsoft Access A submacro is a complete macro with a Submacro header within a macro – Allows you to consolidate related macros and to manage large numbers of macros
XP Submacros (Cont.) New Perspectives on Microsoft Access
XP Submacros (Cont.) New Perspectives on Microsoft Access The Table Name argument specifies the name of a table that will be opened when the macro is run The View argument specifies the view in which the object opens. The Data Mode argument specifies the table’s data- entry options – Allowable settings for this argument are Add (users can add new records but can’t change or delete existing records), Edit (change and delete existing records and can add new records), and Read Only (only view records) – If you don’t select an argument value, Edit is the default setting
XP Adding a Submacro New Perspectives on Microsoft Access The SelectObject action selects a specified object so that you can run an action that applies to the Object The RunMenuCommand action selects and runs a command on the ribbon The PrintSelection argument, which prints the selected form record
XP Adding a Submacro (Cont.) New Perspectives on Microsoft Access
XP Adding a Command Button to a Form New Perspectives on Microsoft Access
XP Attaching a Submacro New Perspectives on Microsoft Access
XP Attaching a Submacro (Cont.) New Perspectives on Microsoft Access
XP Designing a User Interface New Perspectives on Microsoft Access
XP Creating the frmQueries Form New Perspectives on Microsoft Access
XP Adding a List Box to a Form New Perspectives on Microsoft Access
XP Adding a List Box to a Form (Cont.) New Perspectives on Microsoft Access
XP SQL (Structured Query Language) – A standard language used in querying, updating, and managing relational databases – Used mostly in a relational DBMS such as mySQL or Oracle Using SQL New Perspectives on Microsoft Access
XP Viewing a SQL Statement for a Query Using SQL (Cont.) New Perspectives on Microsoft Access
XP SELECT Statement – The basic form of a SQL SELECT statement includes four sections, known as clauses – Each clause starts with a different keyword: SELECT, FROM, WHERE, and ORDER BY – After the SELECT keyword, you list the fields you want to display – After FROM, you list the tables used in the query – After WHERE, you list the selection criteria – After ORDER BY, you list the sort fields Using SQL (Cont.) New Perspectives on Microsoft Access
XP Using SQL (Cont.) New Perspectives on Microsoft Access
XP Using a SQL Statement for a List Box – System tables are special tables maintained by Access that store information about the characteristics of a database and about the structure of the objects in the database – Although system tables do not appear in the Navigation Pane, you can retrieve information from system tables using SELECT statements – One of the system tables, the MSysObjects table, keeps track of the names, types, and other characteristics of every object in a database Using SQL (Cont.) New Perspectives on Microsoft Access
XP Using SQL (Cont.) New Perspectives on Microsoft Access
XP Using SQL (Cont.) New Perspectives on Microsoft Access
XP Adding a Command Button to a Form New Perspectives on Microsoft Access
XP Adding a Command Button to a Form (Cont.) New Perspectives on Microsoft Access
XP Adding a Command Button to a Form (Cont.) New Perspectives on Microsoft Access
XP Creating the Macros for the frmQueries Form New Perspectives on Microsoft Access – Load Event Occurs when Access opens a form or report
XP Creating the Macros for the frmQueries Form (Cont.) New Perspectives on Microsoft Access
XP Creating the Macros for the frmQueries Form (Cont.) New Perspectives on Microsoft Access
XP Testing the frmQueries Form New Perspectives on Microsoft Access After creating a custom form, you should test the form in Form view – For the frmQueries form, you need to double-click a query name in the list box to make sure the query datasheet opens – Also, you must scroll the list box, click a query name, and then click the Display command button to make sure the query datasheet opens, and also click the Preview command button to make sure the query opens in Print Preview
XP Creating a Navigation Form New Perspectives on Microsoft Access
XP Creating a Navigation Form (Cont.) New Perspectives on Microsoft Access
XP Creating a Navigation Form (Cont.) New Perspectives on Microsoft Access
XP Creating a Navigation Form (Cont.) New Perspectives on Microsoft Access