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 ...
Get Access 2010: The Missing Manual 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.