Microsoft Office Tutorials and References
In Depth Information
Chapter 2: Making Macros Smarter
Chapter 2: Making Macros Smarter
In This Chapter
Validating and setting fields in your tables by using data macros
Making your forms smarter with macros
Changing form control properties with a macro
Creating your own main-menu form
Using temporary variables in macros
The macros we describe in this chapter are fired off automatically by
events — that is, by things that happen (usually, things that the
database user does) to tables or forms. Examples of events are a form opening, a
record in a table being added, or the value of a field in a table changing. You
can tell Access that when one of these events happens, it should run a
specific macro. This setup makes your macros event-driven. The events that can
trigger data macros, which are attached to tables, are events that happen
to records in tables. The events that trigger form macros are events that
happen to forms and the objects they contain.
Event-driven macros can be very powerful. You can use them to validate
values in your tables or to set the values of fields based on changes in other
fields. You can also use the On Click event of buttons on a form to run any
macro you want.
Although macros are simple and powerful, they aren’t the full-featured
programming language that Visual Basic for Applications (VBA) is. If you create
a macro and later wish that you’d written a VBA procedure to do the job,
Access can convert the macro to VBA. See Book VIII, Chapter 1 for details on
converting a macro to a VBA program. If you want to use navigation forms
rather than regular forms, see Book IV, Chapter 3.
This chapter describes some nifty ways to use macros with tables and
forms, including setting up your own main-menu form.
Search JabSto ::




Custom Search