The information in this article applies to:
- Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97
SUMMARY
Moderate: Requires basic macro, coding, and interoperability skills.
This article describes how to prompt the user to confirm changes to a
field using a conditional macro.
MORE INFORMATION
This following procedure uses the Employees form in the sample
database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0):
- Create the following new macro and save it as AreYouSure:
Macro Name Condition Action
---------------------------------------------------------
AreYouSure MsgBox("Commit changes?",1)=2 CancelEvent
... SendKeys
AreYouSure Actions
----------------------
CancelEvent
SendKeys
Keystrokes: {ESC}
Wait: NO
NOTE: The ellipsis in the Condition column forces Microsoft Access
to perform the action on that line if the condition on the
preceding line is true. Microsoft Access evaluates macro conditions
as true or false. If the expression is true, Microsoft Access
performs the action; if it is false, Microsoft Access ignores the
action.
- Open the Employees Form in Design view.
- On the View menu, click Properties.
- Click the Title text box to select it.
- Set the properties for the Title text box as follows:
Text box: Title
---------------
Name (or ControlName in version 1.x): Title
ControlSource: Title
BeforeUpdate: AreYouSure
- View the form in Form view and change the information in the Title
field. When a confirmation message appears, click OK to confirm your
change, or click Cancel to cancel your change.
NOTE: This example uses the MsgBox function instead of the MsgBox
action. The MsgBox action has only an OK Button whereas the MsgBox
function can also include a Cancel button.
REFERENCES
For more information about the Message box function, search the Help Index
for "MsgBox Function."
|