When you create a new database, you typically begin by creating a few database objects such as tables, forms, and reports. Eventually, you reach a point where you need to add some programming to automate certain processes and tie your database objects together. In Access, programming is the process of adding functionality to your database by using Access macros or Visual Basic for Applications (VBA) code. For example, suppose you have created a form and a report, and you want to add a command button to the form that, when clicked, opens the report. Programming, in this case, is the process of creating a macro or VBA procedure and then setting the command button's OnClickevent property so that clicking the command button runs the macro or procedure.
In this introductory Visual Basic for Applications (VBA) training course, you will learn how to manipulate objects in Access with VBA. Specifically, you will learn how to use the Visual Basic editor, work with the object model, create and use variables, and use the selection structure. You will learn to use flow control, create custom dialogs, automate processes, and handle errors.
Each lesson of the class begins with a general overview of a feature and then shows how that feature works in Access.
Upon completion of this course students will be able to:
- Understand how the Visual Basic editor works in Access.
- Learn to work with the VBA object model.
- Learn to work with VBA object variables.
- Learn to work with string variables.
- Learn to work with date variables.
- Learn to work with numeric variables.
- Learn to use the selection structure.
- Learn to use the Select Case statement and the MsgBox function.
- Learn to work with the repetition structure.
- Learn to work with option button, check box, and list box controls.
- Learn to use Automation.
- Learn to trap errors.
It is recommended that students have previously attended the following courses, or have equivalent knowledge:
- Microsoft Access Part 1
- Microsoft Access Part 2
- Microsoft Access Part 3
Module 1: Getting Started
Module 2: Working with Procedures and Functions
- Introduction to Programming in Access
- Why Program in Access?
- Understanding the Development Environment
- Using Visual Basic Help
Module 3: Understanding Objects
- Understanding Modules
- Creating a Standard Module
- Understanding Procedures
- Creating a Sub Procedure
- Calling Procedures
- Using the Immediate Window to Call Procedures
- Creating a Function Procedure
- Naming Procedures
- Organizing Code and Procedures
- Working with the Code Editor
Module 4: Using Expressions, Variables, and Intrinsic Functions
- Understanding Classes and Objects
- Navigating the Access Object Hierarchy
- Understanding Collections
- Using the Object Browser
- Working with the Application Object
- Understanding the Form Object
- Working with Properties
- Using the With Statement
- Working with Methods
- Understanding the DoCmd Object
- Working with Events
- Understanding the Order of Events
Module 5: Controlling Program Execution
- Understanding Expressions and Statements
- Declaring Variables
- Understanding Data Types
- Working with Variable Scope
- Working with Variable Lifetime
- Considering Variable Scope and Lifetime Together
- Using Intrinsic Functions
- Understanding Constants
- Using Intrinsic Constants
- Using Message Boxes
- Using Input Boxes
Module 6: Working with Recordsets
- Understanding Control-of-Flow Structures
- Working with Boolean Expressions
- Using the If...End If Decision Structures
- Using the Select Case...End Select Structure
- Using the For...Next Structure
- Using the For Each...Next Structure
- Using the Do...Loop Structure
- Guidelines for use of Branching Structures
Module 7: Debugging Code
- Declaring and Creating Object Variables
- Working with the DAO Recordset Object
Module 8: Handling Errors
- Understanding Errors
- Using Debugging Tools
- Setting Breakpoints
- Setting Break Expressions
- Using Break Mode during Run Mode
- Stepping through Code
- Determining the Value of Expressions
- Understanding Error Handling
- Understanding VBA's Error Trapping Options
- Trapping Errors with the On Error Statement
- Understanding the Err Object
- Writing an Error-Handling Routine
- Working with Inline Error Handling