Microsoft Office Tutorials and References
In Depth Information
Running Macros in Forms
Keyboard shortcuts for command buttons
Some people would rather use the keyboard
than the mouse. You can give your command
buttons keyboard shortcuts, in the form of the
Alt key combined with a letter or number.
To assign a shortcut to a command button,
include an ampersand ( & ) in the Name property
of the control. The keyboard shortcut is the Alt
key combined with the letter or digit that
follows the ampersand. If you name a command
button &Print , for example, its keyboard
shortcut is Alt+P.
Book VI
Chapter 2
To look at or edit an embedded macro, open the form in Design view, display
the Events tab of the property sheet, and click the control to which the macro
is attached. The On Click event of the control says Embedded, and you can
click the Macro Builder ( … ) button to open the macro in Design view. While
you’re editing an embedded macro, you can’t view any other objects in the
database until you close the macro. Embedded macros don’t show up in the
Navigation Pane; they aren’t considered to be separate objects. Those macros
are stored as part of the form to which they’re attached.
Referring to form controls in macros
When you write a macro that runs from a form — whether it’s an embedded
macro or a stand-alone macro that runs from an event on the form — the
macro has to refer frequently to the current value of a control on the form.
In the arguments you use to specify macro actions, you can just type the
name of the control that displays the field or the field name. To set the
shipping charge to $3 per item when the handling charge is $3.75, for example,
you can use the SetValue action with these arguments:
Name: [Shipping & Handling]
Value: ([Total Qty] * 3) + 3.75
If you’re referring to a control on a form other than the form from which the
macro was called, however, you need to specify which form the control is
on, as follows:
[Forms]![ formname ]![ controlname ]
Replace formname with the name of your form and controlname with the
name of the control on the form.
The OpenReport action, for example, displays or prints a report. You can
use its Where argument to restrict the records that appear in the report. If
you want the report to include only records with the same OrderID value
Search JabSto ::




Custom Search