Using Events with FlexPro Objects

23.08.2021

To create an event routine for a FlexPro object event, perform the following three steps:

1.Declare an object variable in a class module so that the events will be answered.

2.Write the specific event procedures.

3.Initialize the declared object from another module.

Declaring the Object Variable

Before you can write the procedures for the events of a FlexPro object, you need to create a new class module and declare an object of the desired type (e.g. FpObject) with events. Let us assume that a new class module called "EventClassModule" is created. The new class module contains the following code:

Public WithEvents oObject As FpObject

Writing Event Procedures

After the new object with events has been declared, it appears in the Object drop-down list box in the class module, and you can write event procedures for the new object. (If you select the new object in the Object list, the valid events for the object are listed in the Procedure drop-down list box.) Select an event from this list. An empty procedure is added to the class module.

Private Sub ObjectoObject_ObjectModified(ByVal Object As Object)

End Sub

Initializing the Declared Object

Before the running the procedure, a connection has to be established between the declared object in the class module "oObj" and the FpObject object. This connection can be set up using the following code from any module:

Dim X As New EventClassModule

Sub Register_Event_Handler()

    Set X.oObject = ActiveDatabase.RootFolder.Object("Formula.FML")

End Sub

Start the "Register_Event_Handler" procedure. Once the procedure has been executed, the oObj object in the class module references the desired FpObject object. The event procedures in the class module are then called as soon as the events occur.

Share article or send as email:

You might be interested in these articles