O'Reilly logo

Access 2010: The Missing Manual by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17. Automating Tasks with Visual Basic

Macros are plenty of fun, but they can do only so much. If you can’t find a readymade macro action that does the job you want, you can’t use a macro. No such limit applies in the world of Visual Basic code, where you can do just about anything (if you spend enough late-night hours at the computer keyboard).

Here are some examples of tasks you can accomplish with code, but not with macros:

  • Modify a whole batch of records at once.

  • Deal intelligently with errors so Access doesn’t pop up a cryptic message.

  • Perform complex calculations. You can calculate an order confirmation code using a secret algorithm, or transform a line of text into Pig Latin.

  • Interact with other programs on your computer. For example, you can copy some data out of a table and into a Word document.

  • Write even more sophisticated validation routines that lock out bad data.

The goal of this chapter (and the next) isn’t to make you a full-time code jockey. If that’s your ambition, you can continue on to read entire books about programming Access. Instead, this chapter aims to teach you just enough to get the low-hanging fruit of Access programming. In other words, you’ll pick up enough VB smarts to use the popular and practical code tricks discussed in the next chapter. You’ll also build a great foundation for future exploration.

Note

The version of Visual Basic that Access and other Office applications use is called VBA, which stands for Visual Basic for Applications.

The Visual ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required