Chapter 7. VBA
Most
applications that are distributed to users include at least some
Visual Basic for Applications (VBA) code. Because VBA provides the
only mechanism for performing certain tasks (for example, using
variables, building SQL strings on the fly, handling errors, and
using the Windows API), most developers eventually must delve into
its intricacies. The sections in this chapter cover some of the
details of VBA that you might not find in the Access manuals. First
you'll find a complete explanation of embedding
strings inside other strings, allowing you to build SQL strings and
other expressions that require embedded values. Two solutions are
devoted to creating a procedure stack, which allows you to keep track
of the current procedure at all times. The second of the two also
creates a profiling log file, which helps you document where and for
how long your code wandered. Next you'll learn about
the DoEvents statement, which gives Windows time
to handle its own chores while your code is running. A group of four
solutions covers the details of creating list-filling functions,
passing arrays as parameters, sorting arrays, and filling a list box
with the results of a directory search. The final two solutions cover
some details of working with Data Access Objects (DAO): how to set
and retrieve object properties, whether the properties are built-in,
and how to tell whether an object exists in your application.
|