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

Three Macro Recipes

So far, you’ve created a basic macro, tried it out, and thought deeply about macro security. It’s about time you got a payoff for all your work and considered a few practical ways to use macros.

The full list of macro actions contains many actions that aren’t that interesting or that relate only to specific project types (like Access projects that front SQL Server databases, which you’ll consider in Chapter 21). The following sections highlight a few of the more useful macro commands. You can check them out in the downloadable content for this chapter, or try the shake-and-bake recipes in your own database.

Find a Record

The FindRecord action works just like the Datasheet Find feature you saw on Searching. You fill in all the search information using arguments.

Let’s say you want to search the Diet field in the AnimalTypes table, looking for the word “hay.” Here are the actions you may use:

  • OpenForm to open the form that you’ll use to display the matching record (in this case, AnimalTypes). You can substitute OpenTable to search using a datasheet.

  • GoToControl to move to the field you want to search (in this case, Diet). If you’re planning to perform a search that spans every field, then you can skip this step.

  • FindRecord to find the text. It’s up to you whether you want to start searching at the first record or the current one, as in this example. You can also choose whether you’ll search for the text anywhere inside the field, or require the whole field value to match ...

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