Event Order Reference that includes VBA exceptions or differences

How would I do that?
This describes how to create a custom event

Although you most definitely can create custom events for your form, you cannot create a new event that responds to a physical user form or control interaction (click, enter, exit, double click, etc.). Your event would more likely be data driven or a wrapper on multiple activities.
For example there is no "RightClick" event. However using the mouse down event and determining if it was button 2 I can raise a custom event called RightClick. That case is more like a wrapper of the mouse down event, although it would work like a RightClick event. The example in the link is a data driven event. If the data meets a condition an event is raised.

they did not provide this particular hook, therefore, you cannot add it
As written, the above statement is incorrect or at least not clear. I believe it means what I said previously, you cannot create a "hook" for a physical interaction. You can most certainly can create a "hook." For example see

This class turns any listbox and a group of command buttons into a sortable listbox where you can move items up and down. I simulate drag and drop using a series of events. I raise a custom "DragDrop" event that returns the index of the item dragged and the index of the item dropped. This however does not really react to the physical drag and drop, but instead is just a wrapper on a some other events and change in data. But once those activities that simulate "drag and drop" complete, I raise the event.

However, going back to this question
I've been looking for an event that gets fired when one closes the first form and then exits to the second form.
Would this simply be the same as the second form trapping when the first form closes?
 
Last edited:
As written, the above statement is incorrect or at least not clear.
they did not provide this particular hook, therefore, you cannot add it
You cannot add it to the MSAccess.exe as an EVENT. Therefore, you cannot create an Event. Any code you create to act as "hook" (my term) must be added to an EXISTING MS Access defined event procedure. THEREFORE, you could use THAT event to serve your purpose rather than fooling yourself into thinking that you are creating an actual event.

This is semantics but it is similar to saying that an .accde is an executable. An .accde is not an executable. "Executable" has a very specific meaning. The .accde is something else and overloading a "word" to make it sound like something else because it is something like the desired "word" is inherently dangerous and causes more confusion.

If it turns out that your "transition" class (you may or not want to use a class) is worthy of reuse for ALL form to form transitions, then go for it. If it is for a specific form to form transition then it is not reusable and you might as well embed it in the event that will trigger it.

Keep in mind that the first form that opens in the database has NO preceding form and the last form to close has NO succeeding form. So, your "class" would most likely have to be tied to a form's Open event (although that will have problems) and it will have to operate correctly with no predecessor. That also means that the "class" never triggers for the last form to close because there is no next form to trigger it. You can get around this though by creating a dummy last form. Actually you would make a dummy first form and hide it as it opens the real first form, then when the real last form closes, there is still the hidden first form and it will close last so it can be used to do cleanup if necessary.

Maybe your desired effect would be achieved by creating a dummy form. No form is ever opened directly, only the dummy form is ever opened. It opens, saves the input form name and the output form name and maybe the PK if that is passed, hides itself and opens the output form as a dialog. Then when the output form closes, the dummy form regains control and does the "transition" whatever it is. In essence you are creating a shell rather than a class or event.
 
Therefore, you cannot create an Event.
I do not know what to say since obviously you can create events. Raise those events and trap those events. This in not conjecture, but clearly something you can demonstrate.
This is not semantics. You might want to specify what you mean, but that blanket statement is incomplete.
If somehow a custom event is not an "event" in your opinion, please educate us on what the hell that means because I am surely clueless on your definition. Maybe it is like the sky is really not blue, but only our perception of the sky is. I guess.
 
I am not doing a good job of explaining the issue or you are deliberately refusing to understand my point. Let's review:
I've been looking for an event that gets fired when one closes the first form and then exits to the second form. Unfortunately, when I switch between the two open forms, the Deactivate event does NOT occurs for the first form, nor the Activate event for the second form. This is because the PopUp property is set to Yes for both forms and it will remain that way!
In theory, the Deactivate event or Activate event should solve the problem. But the Popup property which he seems to be welded to is interfering.

You are suggesting that the OP create a FORM level Event that doesn't exist. OK, there are VBA constructs called "Events" but they are NOT form level events and so they are not triggered by the code that is actually running the form you know the code that MS wrote, and there is no way to raise one when focus (for lack of a better word) leaves a form because the code that is running the form, you know the code that MS wrote, didn't give us that event when the form is a popup.

So, let me try again. Yes, you can create classes. Yes you can create events but YOU must raise those events and that is done with code that is running somewhere in the form's class module. THEREFORE, wherever the code is running is the place where you could perform the action you need to perform, you don't need a new event and you can't create one that gets raised by Access.
 
You are suggesting that the OP create a FORM level Event that doesn't exist
Where in the @#$% did I say anything like that? You just make stuff up to support some non-existent argument. In fact I make no suggestion about anything the OP should or should not do. As I point out, I do not even understand why there is even an issue since you could simply trap the onclose event of any form. Why not read what I wrote, instead of telling me what I am suggesting.
OK, there are VBA constructs called "Events" but they are NOT form level events and so they are not triggered by the code that is actually running the form you know the code that MS wrote, and there is no way to raise one when focus (for lack of a better word) leaves a form because the code that is running the form, you know the code that MS wrote, didn't give us that event when the form is a popup.
So now you are trying to argue back to me what I already clearly stated. That's a new technique.
Although you most definitely can create custom events for your form, you cannot create a new event that responds to a physical user form or control interaction (click, enter, exit, double click, etc.).
You made the blanket statement that you cannot "create events", but we were somehow supposed to interpret that blanket statement to mean some very narrowly focused definition of
but they are NOT form level events and so they are not triggered by the code that is actually running the form you know the code that MS wrote, and there is no way to raise one when focus (for lack of a better word) leaves a form because the code that is running the form, you know the code that MS wrote, didn't give us that event when the form is a popup
You cannot now come back and specify what you meant, and say I am deliberately refusing to listen to your nonsense.
 
I should have said "create form level events" but since we were talking about form level events, I didn't clarify. Would that have been more clear? Are we on the same page yet? You can create all the classes and events you want. The point is that "Access", you know that code that runs that makes everything actually work, won't raise YOUR events. YOU have to raise them. Therefore YOU, at some place in the code know you want to do something because the stars are all aligned. You can call a function or a sub or you can make a custom event or you can just write the code out right where you are if that makes sense to you and the code isn't reusable.

Where in the @#$% did I say anything like that?
The conversation was about form level events so if the solution is a custom event, it would be a form level event.
 

Users who are viewing this thread

Back
Top Bottom