In this chapter, we looked at what APIs and DLLs are, and why you might want to use them. We introduced the concept of static versus dynamic linking and how to reference APIs in Access projects. We then examined the anatomy of an API call, and went into great detail about how to use the correct data types when calling API functions.

We then looked at trapping errors generated by DLLs and the considerations in distributing an application that references Type libraries and custom DLLs.

Although this has been a whirlwind tour of the Windows APIs and their use in VBA, we hope any fear or apprehension you may have had toward using them has been allayed to the point where you are now willing to experiment and learn by doing.


You may be familiar with SQL; after all, it's in every query you create. SQL (Structured Query Language) is the language of queries and recordsets; it's how you retrieve, update, insert, and delete records in your database tables.

When you use the query Design View in Access, you are actually building a SQL statement under the covers. Most of the time you won't need to actually look at the SQL code, but you can see it using the SQL View if you're curious.

Conversely, you can take most SQL statements, paste them into the SQL View of a new query, and then switch over to Design View to see how they work. There are a few types of SQL statements where this won't work; Union queries and pass-through queries are a couple of examples that cannot be viewed using Design View.

Even if you're comfortable using SQL in queries, you may not be familiar with building SQL statements in VBA. If you're not, you're missing out! Using SQL in VBA is a powerful technique that can enable many great features in your Access applications. By using VBA you can build custom SQL statements for combo boxes, forms, and reports. For example, you'll be able to change the sorting and selecting of records on continuous forms, control the record selection on reports, and limit the drop-down lists of combo boxes based on other combo boxes.

First, we'll cover how to build SQL statements using string variables in VBA.

0 0

Post a comment