Examples of macro conditions

Microsoft Office Access 2003

To cause Microsoft Access to temporarily ignore an action, enter False as a condition. Temporarily ignoring an action can be helpful when you are trying to find problems in a macro.

Use this expression To carry out the action if
[City]="Paris" Paris is the City value in the field on the form from which the macro was run.
DCount("[OrderID]", "Orders")>35 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.
Forms![Products]![UnitsInStock]<5 The value of the UnitsInStock field on the Products form is less than five.
IsNull([FirstName]) The FirstName value on the form from which the macro is run is Null (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.
MsgBox("Confirm changes?",1)=1 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.