Subject Re: order of events
From Mervyn Bick <invalid@invalid.invalid>
Date Sat, 19 Sep 2020 10:05:32 +0200
Newsgroups dbase.getting-started

On 2020/09/19 06:52, Ken Mayer wrote:

> I am guessing that "beforeConnect" would have to do with the database
> object, not the query ... this event handler doesn't appear in help for
> the ado objects (although I know that the help for ADO isn't as
> up-to-date as it should be). I would check that, first.
>
> However, think it through. *IF* this is a real event handler,
> beforeConnect would logically have to fire before you could open the
> query, because you would have to connect to the database first. Then you
> could attempt a canOpen to open the query itself. Does that make sense?

The beforeConnect event is real enough.  It is an event of the ADOquery
object and it actually works. :-)  It is visible in the Inspector and
one can assign an event handler to it.

The ADOquery object also has beforeExecute and beforeRelease events.  I
set up a little test form with print statements in the event handlers
and they fired in this order.

When the form opens
beforeConnect
onConnect
canOpen
beforeExecute
onExecute
onOpen

When the form closes
canClose
onClose
beforeRelease

I didn't spend much time on this so I haven't found what triggers the
beforeExecute and onExecute events other than when the instance of the
object is created.  They don't fire when navigating in the table.  The
onProgress event didn't fire at all but this was to be expected as the
test form does nothing to trigger it.

>> I guess that my underlying question is whether there is always a
>> built-in order for each and every event to be fired for a given object
>> or do some events fire according to the order they appear in the code?
>> and if there is a hard-coded order, is there somewhere that I can look
>> up theĀ  order for a given object?

Ken answered this but if you are ever in doubt as to the order in which
events are triggered simply add a temporary print statement to each
event handler.


> "before" is not a normal event handler in dBASE, so I can't speak to it
> .... but I would think it would fire either before the canEvent, as
> noted above. I do little with ADO (did some testing for my books, but
> don't use it normally).

There are six of them listed in the help file apart from those
applicable to ADO objects.

Mervyn.