Handling an ODBC event
Events precede and follow many methods, as listed in the documentation. They have names such as BeforeConnectTo, AfterConnectTo, BeforeNextRow, and AfterNextRow. If you write an event handler and bind it to the event with the On Event statement, the handler is called when the event occurs.
The On Event statement must state the name of the event and the name of the ODBCConnection, ODBCQuery, or ODBCResultSet object that activates the event. The following example calls a sub named AfterPositionChange after any call to the NextRow method, where result is an ODBCResultSet object:
On Event AfterNextRow From result Call AfterPositionChange
The first parameter of the subroutine is the object that activated the event. In the following example, the parameter res accepts the ODBCResultSet object that activated the AfterNextRow event:
Sub AfterPositionChange(res As ODBCResultSet)
Messagebox res.CurrentRow,, "Current row"
End Sub