Coding RDO Event Handlers

RDO 2.0 exposes a wide variety of events that can make handling asynchronous operations, centralized error handling, or common routine handling far easier to implement. These event procedures are all enabled when the initial RDO object is created. Basically, when you use WithEvents with the Dim statement, the object's event handlers are exposed to your code. For example, to expose the events on an rdoConnection object, you can code the following:

Private WithEvents MyCn As rdoConnection

In design mode, the Object dropdown in the code window will include an entry for MyCn. Once selected, each of the rdoConnection events are exposed.

While you cannot use the WithEvents operator with the Dim x As New syntax, you can use the following syntax to instantiate stand-alone RDO objects.

Private WithEvents MyCn As rdoConnection
...
Set MyCn As New rdoConnection

Note that the rdoQuery object does not expose any events — these are exposed on the parent rdoConnection instead. Each rdoConnection event handler that traps events for the rdoQuery objects is passed a pointer to the query that is causing the event. For example, the rdoConnection object's WillExecute event could be coded as follows to display the SQL about to be submitted as a query.

Private Sub MyCn_WillExecute( _
   ByVal Query As RDO.rdoQuery, Cancel As Boolean)
Msgbox "About to exectue:" & Query.SQL
End Sub

For More Information   More detail on using the WithEvents keyword is available in "Adding Events to a Class" in "Programming with Objects" in the Programmer's Guide, and in the Language Reference".