Example of using a macro to display related records when you move between records

When you move between supplier records on a Suppliers form, you might want to see the products each supplier carries in a Product List form. You can accomplish this by carrying out an OpenForm action in a macro that runs in response to the Supplier form's Current event. You can make the Product List form display records whose value in the SupplierID field in the underlying table matches the value in the SupplierID field on the Suppliers form. Set the action's Where Condition argument as follows:

[SupplierID]=Forms![Suppliers]![SupplierID]

Tip   If you don't always want the Products form to open when you move between records on the Suppliers form, include a conditional expression in the macro that checks whether or not the Product List form is open.

Display records in another table by using a macro

After creating the macro, set the Suppliers form's OnCurrent event property to the name of the macro.