The very last task you should perform before placing your application in production is to compile and save all your Visual Basic procedures. When you do this, Access stores a compiled version of the code in your database. Access uses the compiled code when it needs to execute a procedure you have written. If you don’t do this, Access has to load and interpret your procedures the first time you reference them-each and every time you start your application. For example, if you have several procedures in a form module, the form will open more slowly the first time because Access has to also load and compile the code.
To compile and save all the Visual Basic procedures in your application, open any module-either a module object or a module associated with a form or report. Choose Compile project-name from the Debug menu, as shown in Figure 24–18. If your code compiles successfully, be sure to save the result by choosing File, Save or by clicking the Save button on the toolbar. (If you have errors in any of your code, the compiler halts on the first error it finds, displays the line of code, and displays an error message dialog box.) After successfully compiling and saving your Visual Basic project, close your database and compact it, as described in Chapter 5, “Modifying Your Table Design.”
Figure 24–18: Choose the Debug, Compile project-name command to compile all the Visual Basic procedures in your database.
As you’ve seen in this book, you can quickly learn to build complex applications. You can use the relational database management system in Access 2007 to store and manage your data locally or on a network, and you can access information in other popular database formats or in any server-hosted or mainframe-hosted database that supports the Open Database Connectivity (ODBC) standard. You can get started with macros to become familiar with event-oriented programming and to prototype your application. With a little practice, you’ll soon find yourself writing Visual Basic event procedures like a pro. In the final chapter, you’ll learn how to set up your application so that you can distribute it to others.