Log In    |    Knowledge Base    |    4D Home
Tech Tip: FORM Event vs. Form event code
Published On: January 25, 2024

There are two 4D commands that capture form events when they occur: Form event code and FORM event.

The main difference is that Form event code only returns an integer constant of the event that just happened, while FORM event returns an object with additional attributes.

Both commands are viable options to use in event handling:

  • Form event code can be used in situations where you only need to know the event that just occurred (via an integer constant).

  • FORM event, on the other hand, offers more capability as it not only returns the integer value, but also the actual name of the event as well as the form element that triggered the event. This allows for cleaner coding when it comes to complex form objects such as listboxes—as the entire object itself can operate at different levels (i.e., listbox, columns, headers/footers).

  • // execute different scenarios based on the part of the listbox that triggered the event
    Case of
       : (FORM Event.objectName="ListBox")
       // ... insert code execution here
       : (FORM Event.objectName="Column1")
       // ... insert code execution here
       : (FORM Event.objectName="ColumnHeader1")
       // ... insert code execution here
       : (FORM Event.objectName="ColumnFooter1")
       // ... insert code execution here
    End case