4.1 Convert Queries into Embedded SQL Statements

Chapter 7. Exploring VBA in Microsoft Access

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.

 

A Note on Conventions

The replacement of Embedded Basic with VBA is one of the most significant changes that occurred with the introduction of Microsoft Access for Windows 95. Because of this addition, Access can share a great deal of code with other VBA-equipped applications, such as Microsoft Excel, Project, and Visual Basic. It has inherited new language constructs and got a new integrated development environment (IDE) for free. When we refer to Visual Basic, VBA, or Access Basic in this chapter, we're referring to the version of VBA that Access supports as its programming language.

 



Access Cookbook
Access Data Analysis Cookbook (Cookbooks)
ISBN: 0596101228
EAN: 2147483647
Year: 2005
Pages: 174

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net