You can use any expression (expression: Any combination of mathematical or logical operators, constants, functions, and names of fields, controls, and properties that evaluates to a single value. Expressions can perform calculations, manipulate characters, or test data.) that evaluates to True/False or Yes/No in a macro condition (condition: Part of the criteria that a field must meet for searching or filtering. Some conditions must be used with a value; for example, the field Author with the condition equals with the value Jane.). The macro will be executed if the condition evaluates to True (or Yes).
Tip In Access 2010, the Macro Builder is all-new and easier than ever!
Watch a video or try Office 2010.
|Use this expression
||To carry out the action if
||Paris is the City value in the field on the form from which the macro was run.
||There are more than 35 entries in the OrderID field of the Orders table.
|DCount("*", "Order Details", "[OrderID]=Forms![Orders]![OrderID]")>3
||There are more than three entries in the Order Details table for which the OrderID field of the table matches the OrderID field on the Orders form.
|[ShippedDate] Between #2-Feb-2001# And #2-Mar-2001#
||The value of the ShippedDate field on the form from which the macro is run is no earlier than 2-Feb-2001 and no later than 2-Mar-2001.
||The value of the UnitsInStock field on the Products form is less than five.
||The FirstName value on the form from which the macro is run is Null (Null: A value you can enter in a field or use in expressions or queries to indicate missing or unknown data. In Visual Basic, the Null keyword indicates a Null value. Some fields, such as primary key fields, can't contain a Null value.) (has no value). This expression is equivalent to [FirstName] Is Null.
|[Country]="UK" And Forms![SalesTotals]![TotalOrds]>100
||The value in the Country field on the form from which the macro is run is UK, and the value of the TotalOrds field on the SalesTotals form is greater than 100.
|[Country] In ("France", "Italy", "Spain") And Len([PostalCode])<>5
||The value in the Country field on the form from which the macro is run is France, Italy, or Spain, and the postal code isn't five characters long.
||You click OK in a dialog box in which the MsgBox function displays "Confirm changes?". If you click Cancel in the dialog box, Microsoft Access ignores the action.