Microsoft Office Tutorials and References
In Depth Information
Using Temporary Variables in Macros
3. Save the macro by pressing Ctrl+S or clicking the Save button on the
Quick Access toolbar.
You can’t assign the macro name to the command button’s On Click
property if the macro isn’t saved.
4. Switch to the form in Design View by clicking the form’s tab.
If your main-menu form isn’t open in Design view, open it now. (In the
Navigation Pane, right-click the form name and choose Design View from
the contextual menu.)
5. Click the Button button in the Controls group on the Design tab of the
Ribbon and then click the form where you want the button to appear.
Access starts the Command Button Wizard. The wizard creates a
command button and starts asking questions.
6. Click Cancel to dismiss the wizard.
7. Move or resize the command button as you like, and create a label to
go next to it.
8. Set the button’s properties to display the text or picture you want.
Book IV, Chapter 3 describes how to configure a command button.
9. Set the button’s On Click event property to run the macro you
created in Steps 2 and 3.
10. Save the macro and the form.
11. Try out your new button!
Using Temporary Variables in Macros
Now that Microsoft has decided that macros are here to stay, it has decided
to beef up the features of macros. One fairly new feature is temporary
variables — variables that are like fields that belong to no table. You can use
a temporary variable to store a value that you’ll need later in the macro’s
execution. You can make as many temporary variables as you like — well, up
to 255, but that’s a lot! — and they stick around even after your macro stops
running. You can set a temporary variable in one macro and read its value in
another macro, or when the same macro runs again later.
Each temporary variable has a name that you choose. To create a temporary
variable or change the name of an existing one, use the SetTempVar action
in your macro. It has two arguments:
Name: A name that you create, such as RecordID
Expression: The value to assign to (or store in) this temporary
variable, which can be any expression
Search JabSto ::

Custom Search