Sample Code from
Access VBA Programming for Dummies

Much of the code in the book is written in "skeleton form" or, in such a way that you can drop it into your database as-is. (Though, the latter type of code is rarely possible to write). Most of the larger chunks of code are available in the databases below, organized by chapter number.

To download a database, click its name, then choose Save when give the Open/Save options. Navigate to the folder in which you want to place the database (e.g. My Documents), and click Save.

All of the files are zipped because many browsers won't let you download .mdb file. So after you've completed the download, be sure to unzip the downloaded file. In Windows XP and Vista you can just right-click the .zip file and choose Extract all. Work only with the extracted .mdb file after that. (You can delete the .zip file if you like).

Once the database is on your computer and unzipped, you can open it just by double-clicking its icon. Within each database, look to the Forms and Modules containers for items relevant to the book. (Sizes below are for the unzipped .mdb file)

Chapter

Samples Database

6 Change Form Control Properties.zip (216KB)
7 Skeleton Code for ADODB Recordsets.zip (112KB)
8 Loop Through Collections Skeleton.zip (136KB)
9 Dialog Box Tools.zip (468KB)  (See below for spin buttons)
10 Fancy SkipLabels Forms.zip (626KB)
11 PCase Function.zip (128KB) , NumWord Function.zip (128KB)
12 Get External Access Data.zip (104KB)
13 Office Automation Skeletons.zip (112KB)

Note: Your security warnings may go ballistic when you download a database, just because each database contains VBA code. I assure there aren't any worms, viruses, Trojan horses, or any other kind of malicious code in the database. I'd have to be stupid, crazy, or some combination thereof to put malicious code into something that's so easily traced back to me!

If a Database Won't Open...

If Access absolutely refuses to open a downloaded database, first make sure you're opening then uncompressed .mdb file. Then you can Unblock the .mdb file so it will open. Here's how:

  1. On your own computer, right-click the icon of the .mdb file you downloaded and choose Properties.
  2. Click the Unblock button near the bottom of the Properties dialog box (see below), then click OK.

You should be able to open the database now just by clicking (or double-clicking) its icon.

Spin Buttons

     Right-click any spin button below and choose Save Picture As to save.

Extras

RoloButtons.zip (472KB): A set of Rolodex-style buttons (see below) that users can click to quickly jump to any section of a lengthy table. After downloading, see the RolobuttonsExample form for an example. Then see the Instructions for Use form for instructions on adapting the buttons to your own database. (You only have to change one word in the VBA code!).

Rolodex-style search buttons at top of a form

For entire databases sometimes used as general examples in the book, see www.coolnerds.com/access.

Related Sites


Back