A.2. Chapter 2

  1. A module is a storage container for your VBA code. Modules can either be standard modules or class modules. Standard modules are not associated with a particular object. Class modules can either be associated with forms or reports or be based on custom-defined objects.

  2. A sub procedure performs a particular action. A function performs a particular action and also returns a particular result. When you need to obtain some type of result based on the action, such as a value that was calculated, you should use a function. An example of a function is one that calculates sales tax and returns the sales tax amount. An example of a procedure is one that displays a message to the user or runs a database update.

  3. You can control the flow of code execution using If ... Then statements, Select ... Case statements, loops, conditional If statements, and IIf statements, as a few examples. Variables can be declared to store various values. Variables can then be used as part of the statements that control code execution to determine if certain conditions are met or whether certain actions should be taken.

  4. Naming conventions involve naming your variables and objects in a particular way, such as with prefixes, which makes them easier to understand without tracking down the declaration or first use in code. Code documentation is important to illustrate how your program works and makes it much easier for you and others to debug and maintain the program in the future. Ideally, your code should ...

Get Beginning Access™ 2007 VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.