Microsoft Office Tutorials and References
In Depth Information
Using Temporary Variables in Macros
To refer to the temporary variable later so that you can use the value it
contains, type an expression like this:
[Tempvars]![ varname ]
Replace varname with the name of the temporary variable.
If the temporary variable doesn’t exist, Access doesn’t complain. Instead,
you get the value Null as the value of the nonexistent temporary variable.
To delete a temporary variable, you can use the RemoveTempVar action.
Nobody’s perfect: Dealing with errors
Originally, when a macro ran into a problem
(like a reference to a record or control that
didn’t exist, or an expression that divided a
number by zero), it just died, displaying a
message for the user to see. Error handling allows
the macro to detect an error and do something
If you want macros to try to handle any errors
that may arise, you can use the On Error
action to tell Access what to do if it runs into
an error. Set the action’s Go To argument to
one of these options:
✓ Next Just ignore the error and go on to :
the next action in the macro.
✓ Macro Name Run a macro. Set the :
Macro Name argument to the macro you
want it to run.
✓ Fail Give up and display an error message. :
If you choose Next or Macro Name , your
macro can find out what the error was by
looking at [Macro Error].[Number] to
see the error number or [Macro Error].
[Description] to see a description of the
error. You can use an If action to determine
what to do, depending on the type of error.