Freigeben über


Using the right syntax when publishing Access macros to Web databases

Macros play a much bigger role in Access 2010 than in previous versions. In fact, using a macro is the only way to automate tasks in Web objects and in applications that you publish to Access Services.

One area that has caused confusion involves using the correct syntax in a macro.

First of all, there are two classes of macro arguments, each of which requires very different syntax.

The first class of macro argument is a string. An example is the Message argument of the MessageBox macro action. To specify a message, enter a string in the argument, without quotes:

 

However, you can also enter an expression in this argument by entering an equal sign, and then entering an expression. Like all expressions, strings need to be enclosed using quotation marks:

The other class of argument is stated in the form of an expression. An example of this type is the WhereCondition argument of the SetFilter macro action. In the Macro Designer, these arguments display an equal sign before and outside the argument text box, to highlight to the user that the argument must be expressed in the form of an expression.

 

Important considerations when using expression argument

What is "double expression" and why should I care?

"Double expression" or "double evaluation" occurs whenever one expression is nested inside another. In an expression argument, if you enter an equal (=) sign in the text box, the expression will be evaluated twice -- once for your equal sign and once for the equal sign that appears before and outside the argument text box.

Why should you care? Because if you are using an expression argument in a Web database macro, the syntax must be correct or you will get a run-time error each time your macro is run. Double expression is not supported in Access Services applications. If you have a macro argument that results in double expression, a run-time error will occur each time your macro is run.

Bottom line: If you are using an expression argument in a Web database macro, do not enter an equal sign at the beginning of the expression.

In general ...

If you are using an expression argument in a client database macro, you should not enter an equal sign at the beginning of the expression unless you have a specific need for it. Note: Double evaluation results in a very slight performance hit every time your macro is run.

Regardless of database type, all strings in expression arguments must be enclosed using quotation marks.