Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA By Robert T. Grauer Maryann Barber.

Slides:



Advertisements
Similar presentations
Using VB with MS Applications R. Juhl, Delta College.
Advertisements

Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Using Macros and Visual Basic for Applications (VBA) with Excel
Developing an Excel Application
Tutorial 8: Developing an Excel Application
Tutorial 12: Enhancing Excel with Visual Basic for Applications
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
Microsoft Excel 2003 Illustrated Complete with Excel Programming.
Exploring Office Grauer and Barber 1 Creating More Powerful Applications: Introduction to VBA(Wk9)
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Exploring Microsoft Access 2003 Chapter 8 Creating More Powerful Applications: Introduction to VBA.
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
Using the Visual Basic Editor Visual Basic for Applications 1.
Chapter 7: Sub and Function Procedures
1 Chapter 1 Tour of Access. 1 Chapter Objectives Start and exit Microsoft Access Open and run an Access application Identify the major elements of the.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Access Tutorial 10 Automating Tasks with Macros
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Microsoft Excel 2007 © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line.
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
Tutorial 11 Using and Writing Visual Basic for Applications Code
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Access 2010 by Robert Grauer, Keith.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Introduction to VBA MGMI Aug What is VBA? VBA = Visual Basic for Application Excel’s powerful built-in programming language An event-driven.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
® Microsoft Access 2010 Tutorial 11 Using and Writing Visual Basic for Applications Code.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Five More on the Selection Structure.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Using Visual Basic for Applications (VBA) – Project 8.
Exploring Microsoft Office XP - Microsoft Word 2002 Chapter 71 Exploring Microsoft Word Chapter 7 The Expert User: Workgroups, Forms, Master Documents,
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 11 Committed to Shaping the Next Generation of IT Experts. Chapter 10 Customizing a Database.
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Five More on the Selection Structure.
OCC Network Drives  H:\  P:\ 
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA.
Microsoft Access 2013 ®® Tutorial 10 Automating Tasks with Macros.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Access Lesson 11 Creating and Running Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Exploring Microsoft Access Chapter 7 Building Applications: The Switchboard, Macros, and Prototyping.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
1 Access Lesson 1 Understanding Access Fundamentals Microsoft Office 2010 Fundamentals Story / Walls.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and
Topics Graphical User Interfaces Using the tkinter Module
1. Introduction to Visual Basic
Microsoft Access Illustrated
Microsoft Office Illustrated
Microsoft Excel 2003 Illustrated Complete
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
Chapter 7 Advanced Form Techniques
Exploring Microsoft Excel
Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy
Chapter 15: GUI Applications & Event-Driven Programming
Tutorial 11 Using and Writing Visual Basic for Applications Code
Presentation transcript:

Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA By Robert T. Grauer Maryann Barber

Exploring Microsoft Office - Microsoft Access Chapter 8 2 Objectives (1 of 2)  Describe relationship of VBA to Microsoft Office  Describe components of the Module window  Describe two ways to create an event procedure  Explain how the Quick Info and Complete Word features simplify entry of VBA statements  Create a combo box to locate a record on a form

Exploring Microsoft Office - Microsoft Access Chapter 8 3 Objectives (2 of 2)  Describe MsgBox parameters  Create an event procedure to facilitate data entry through keyboard shortcuts  Create an event procedure that substitutes an application-specific message for the standard Access error messages  Describe several types of data validation

Exploring Microsoft Office - Microsoft Access Chapter 8 4 Overview  VBA is a programming language to build truly useful Access applications  VBA is event driven: Procedures respond to specific events  VBA can modify procedures that Access has already created  Provide an appreciation for what can be accomplished with VBA

Exploring Microsoft Office - Microsoft Access Chapter 8 5 Introduction to VBA  Data validation  Facilitate data entry, including creating keyboard shortcuts  Error trapping  Enhance communication with the user by using message boxes

Exploring Microsoft Office - Microsoft Access Chapter 8 6 Modules and Procedures  Visual Basic code is developed in units called procedures  Event procedures: run automatically in response to an event  General procedures: called explicitly from within another procedure

Exploring Microsoft Office - Microsoft Access Chapter 8 7 Modules  All procedures are stored in modules; one module contains one or more procedures  Every form in Access has its own module (Class module), which contains procedures for that form  Private procedure: accessible only from within the module in which it is contained  Public procedure: accessible from anywhere  Module window: where procedures in a module are displayed and edited

Exploring Microsoft Office - Microsoft Access Chapter 8 8 Module Window Name of procedure (Form_Close) MsgBox statement Name of next Procedure (Form_Current) End of procedure

Exploring Microsoft Office - Microsoft Access Chapter 8 9 MsgBox Statement  MsgBox takes three arguments (known as parameters)  Prompt: Specifies the message text  Buttons: Type of command buttons and icon  Title: Text that appears in title bar of the message box

Exploring Microsoft Office - Microsoft Access Chapter 8 10 Create an Event Procedure Select Event tab Click On Current Select Code Builder Right click on Form Selector box and choose Properties

Exploring Microsoft Office - Microsoft Access Chapter 8 11 On Current Event Procedure Procedure header Name of Combo Box from step 3 Complete Word will provide completion options

Exploring Microsoft Office - Microsoft Access Chapter 8 12 Facilitating Data Entry  Use the Default property to specify default values for certain fields  Use VBA to create keyboard shortcuts  A KeyDown event procedure can implement keyboard shortcuts

Exploring Microsoft Office - Microsoft Access Chapter 8 13 KeyDown Event Procedure Select Form in the Object list box Select KeyDown from the Procedure List box Key words Appear in blue

Exploring Microsoft Office - Microsoft Access Chapter 8 14 ShortCut Command Button Select the command button Properties All tab Change Name to ShortCutButton Change Caption to &ShortCuts Command Button tool

Exploring Microsoft Office - Microsoft Access Chapter 8 15 Error Trapping  Produce more user-friendly error message  Find the error number using the Immediate window  Use case statements to test the value of an incoming variable and produce the appropriate statement  Once error is detected, Call MsgBox statement to display your user-friendly error message  Else will execute if all Case statements fail

Exploring Microsoft Office - Microsoft Access Chapter 8 16 Error Event Procedure Case 1 Error numbers Case 2 Else statement

Exploring Microsoft Office - Microsoft Access Chapter 8 17 Data Validation  Invalid data corrupts validity of information  Data validation is therefore crucial  Use VBA to extend data validation capabilities within Access  Use a nested IF statement to remind users to leave no fields empty

Exploring Microsoft Office - Microsoft Access Chapter 8 18 MsgBox Function vs. Statement  MsgBox function: displays a prompt to the user, then returns a value - Requires parentheses around arguments  MsgBox statement: simply displays a message, does not use parentheses

Exploring Microsoft Office - Microsoft Access Chapter 8 19 Chapter 8 Summary (1 of 2)  VBA is a subset of Visual Basic  VBA is accessible by all Microsoft Office applications  All VBA procedures are stored in modules  Every form in Access has its own module that contains the event procedures for that form

Exploring Microsoft Office - Microsoft Access Chapter 8 20 Chapter 8 Summary (2 of 2)  All procedures are either public or private: Private—accessible only from within its module public—accessible from anywhere  Event procedures were created to illustrate how VBA is used to improve an application  MsgBox function has three arguments: message, intrinsic constant, and title bar message