A Few Differences
Microsoft Access 2 uses Access Basic as its scripting language. When I wrote this tutorial, Access was (is) at version 8 (aka, Access 97), which uses Visual Basic for Applications (VBA) as its scripting language. Fortunately, there are few differences between Access 2's Access Basic and Access 8's VBA. The main differences I have found, as applicable to these example scripts, I show below on this page.SPECIAL NOTE: In a real script, each of the following examples would be printed on one line only. Lines of text are allowed to wrap in the examples below, only so the text can fit inside the table cells on this web page.
| Access (v2) Basic | VBA for Access (v8) 97 |
| DoCmd RunSQL (UtilStrg0)1 | DoCmd.RunSQL UtilStrg01 |
| DoCmd Hourglass True1 | DoCmd.Hourglass True1 |
| Set DogDB = DBEngine.Workspaces(0).Databases(0)2 | Set DogDB = CurrentDb( )2 |
| UtilVart0 = SysCmd(SYSCMD_INITMETER, "Preparing topic names ...", ProgShow)3 | UtilVart0 = SysCmd(acSysCmdInitMeter, "Preparing topic names ...", ProgShow)3 |
1UtilStrg0 is a string variable. DoCmd is now treated as an object, and macro actions are now treated as methods for the DoCmd object, hence the separating period (.) character. See the online Access help for details about the DoCmd object and its methods. | |
Use the Access Online Help
If, while building your VBA scripts, you encounter syntax errors or other difficulties, I suggest you make extensive use of the online Help for Microsoft Access to solve those difficulties. The online Help for Access VBA is pretty good. It has excellent examples, explanations, search words, and cross-references. Right-click on the open help screens that display code examples, and select "Print". Then carefully study the printed examples and explanations as you need them.