Triggers are blocks of code that run immediately upon completion of the event to with which they are associated. Trigger events exist at the database, table and field level as displayed below.
At the database application level, code may be initiated immediately upon a user logging into the database itself. This Trigger After Open is available in Administrative mode, from the Desktop in the Options window.
At the table level, code may be initiated immediately upon a user creating a new record in the table or modifying the contents of an existing record in the table. These Trigger on Create and Trigger After Update fields are accessed in the Table Management Window as displayed and highlighted in the image above.
At the field level, code may be initiated immediately upon a user updating (modifying) the contents of the field itself. Field triggers are particularly useful for setting default values for fields in a record based on a selection in another field. For example, in an invoice line item table, there are fields for item and item price. The item is selected from the inventory field where all of the details of each item, including the recommended retail selling price, are maintained. In this situation, the item price field should be updated with the value of the ‘Suggested Retail Sales Price’ field from the inventory table as soon as an inventory item is selected for inclusion on the invoice. It is impossible to set this default value within the price field itself because it is completely dependent on the inventory item being sold on that line and this is not known until runtime. A Trigger After Update block of code can be used to make the line item price field equal to the inventory item price field immediately upon selection of the item itself.