Entering and Running the Sample Programs

If you’ve downloaded the sample file from O’Reilly & Associates, your database already includes a code module, Examples, that contains all of the book’s sample VBA programs. If not, you can create a code module yourself and enter programs into it. To create the code module:

  1. Select the Modules tab when the Library database is open in the Database window.

  2. Click on the New button to create a new code module.

  3. When Access opens a new code module (which it will usually name Module1, unless your database already contains code modules saved with their default names), click on the Save button on the toolbar.

  4. When Access displays the Save As dialog, enter the name of your new code module, Examples, in the Module Name text box and click OK.

You can then begin entering code for each of the program examples. To do this, for each code example:

  1. Select the Procedure option from the Insert menu.

  2. When Access opens the Insert Procedure dialog, enter the name of the procedure in the Name text box. Since all of the programs listed in the book are subroutines, you don’t have to worry about the dialog’s other options. Just click OK.

To run a program:

  1. Select the Modules tab in the Database window, and open the Examples module.

  2. Select the Debug Window option from theView menu.

  3. When Access opens the Debug window, simply type in the name of the program you’d like to run.

Get Access Database Design and Programming, Second Edition 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.