O'Reilly logo

Access™ 2007 Bible by Gavin Powell, Joseph C. Stockman, Jennifer Reardon, Michael R. Groh, Michael R. Irwin, Cary N. Prague

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Mastering VBA Data Types and Procedures

IN THIS CHAPTER

  • Using variables

  • Understanding the VBA data types

  • Understanding subs and functions

  • Creating VBA procedures

  • Creating functions

  • Calling procedures and functions

  • Passing parameters to procedures and functions

  • Handling values returned from a function

All VBA applications require variables to hold data while the program executes. Variables are like a white board where important information can be temporarily written and read later on by the program. For instance, when a user inputs a value on a form, you'll most often use a variable to temporarily hold the value until it can be permanently stored in the database or printed on a report. Simply put, a variable is the name you've assigned to a particular bit of data in your application. In more technical terms, a variable is a named area in memory used to store values during program execution.

Variables are transient and do not persist after an application stops running. And, as you'll read in the "Understanding variable scope and lifetime" section, later in this chapter, a variable may last a very short time as the program executes or may exist as long as the application is running.

In most cases, you assign a specific data type to each of the variables in your applications. For instance, you may create a string variable to hold text data such as names or descriptions. A currency variable, on the other hand, is meant to contain values representing monetary amounts. You should not ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required