What event gets triggered

DanielR

Registered User.
Local time
Today, 08:49
Joined
Mar 16, 2018
Messages
72
I have 2 forms open. I close one of the two forms. Does any event get triggered in the form that stays open?
I tried to set focus to the form that stays open hoping that the gotfocus event will get triggered but it doesn't.
The form current event doesn't get triggered either.
How do I trigger an event when the first form closes?
 
Depends what event you want to occur.
Possibly add code to the Form_Close event
 
My first suggestion would be to use the Close event on the form that's closing.

Otherwise, while there is no built-in trigger in a form that goes off when another form closes, you can use the Activate trigger as long as the form has lost focus at some point. The catch is that it fires ANY time the form regains focus after losing it.
 
Hi Frothy
My trigger got activated before yours!
 
nothing happens to form2 if you close form1.
you can build a routine in f2, make it public sub of the form.

public sub MyEvent

then THAT you can call from form1 before closing
Code:
forms!form2.MyEvent
me.close "form1"
 
Awesome...creating an event which I call when I close the form works. Thank you everyone.
 
FWIW, Form2 can sink an event that Form1 raises...
Code:
private [COLOR="Blue"]WithEvents[/COLOR] m_frm as Access.Form

private sub cmdShowForm1_Click()
[COLOR="Green"]'  this is a click handler that opens Form1 from Form2[/COLOR]
   const FN as string = "Form1"
   docmd.openform FN       [COLOR="Green"]' open Form1[/COLOR]
   set m_frm = forms(FN)   [COLOR="green"]' assign to local WithEvents variable[/COLOR]
   m_frm.OnClose = "[Event Procedure]"
end sub

private sub m_frm_Close()
[COLOR="green"]'  this routine, on Form2, handles the close event of Form1[/COLOR]
   msgbox m_frm.name & " is closing."
end sub
Mark
 
Mark,
That's very cool...thank you for your help.
I will try that. :)
 

Users who are viewing this thread

Back
Top Bottom