Solved How to refer Exit button onClick event (1 Viewer)

tihmir

Registered User.
Local time
Yesterday, 21:41
Joined
May 1, 2018
Messages
216
Hi everyone,
On my unbounded pop up form "frmProducts" I need to write code that when I press Exit button onClick evetn to refer that:
Code:
If combobox (cboType) on my subform "subfrmPSD" is = "somename" then
    DoCmd.GoToControl "InspectionTab"
ElseIf my subform "subfrmPSD" is = "somename" then
    DoCmd.GoToControl "InspectionTab"
End If
The name of main form is frmInspection
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:41
Joined
Oct 29, 2018
Messages
18,962
Hi. Not sure I understand. You have a popup form and when you click an exit button on this form, you want something to happen to another form/subform that's already open?
 

tihmir

Registered User.
Local time
Yesterday, 21:41
Joined
May 1, 2018
Messages
216
Hi. Not sure I understand. You have a popup form and when you click an exit button on this form, you want something to happen to another form/subform that's already open?
No, I need depending on what choice is made on combobox "cboType" on subfrmPSD, when I presse the Exit button On my unbounded pop up form "frmProducts" to open different tab pages.
Something like that, but this is for subform2 to subform1
Code:
If Me.[Parent]![cboType] = "somename" Then
      DoCmd.GoToControl "PrescriptionTab"
ElseIf Me.[Parent]![cboType] = "act" Then
      DoCmd.GoToControl "actTab"
End If
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:41
Joined
Oct 29, 2018
Messages
18,962
No, I need depending on what choice is made on combobox "cboType" on subfrmPSD, when I presse the Exit button On my unbounded pop up form "frmProducts" to open different tab pages.
Something like that, but this is for subform2 to subform1
Code:
If Me.[Parent]![cboType] = "somename" Then
      DoCmd.GoToControl "PrescriptionTab"
ElseIf Me.[Parent]![cboType] = "act" Then
      DoCmd.GoToControl "actTab"
End If
Hi. But since we can't see your forms, it's hard to understand what you're asking. Can you post some screenshots?
 

tihmir

Registered User.
Local time
Yesterday, 21:41
Joined
May 1, 2018
Messages
216
He
Hi. But since we can't see your forms, it's hard to understand what you're asking. Can you post some screenshots?
Here is my database and what I need is:
On my main form "frmInspection" on subform "frmPSD" I have cboAscertainment and cboNumberOfProducts.
The cboAscertainment has 2 оptions - "no violations" and "violations".
When I number in cboNumberOfProducts it automaticly open popup form "frmProductsPopUp"
So, what I need is when I'm done filling out this form ("frmProductsPopUp" ) and press the Exit button I want to open different tabs depending on what choice is made on cboAscertainment (which is located on frmPSD).
1-If cboAscertainment = "no violations" Then go to prescriptionTab
2-If cboAscertainment = "violations" Then go to actOfViolationTab
 

Attachments

  • DB_EN_v1.accdb
    2.3 MB · Views: 420

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:41
Joined
May 7, 2009
Messages
16,393
check and test
 

Attachments

  • DB_EN_v1.accdb
    2.3 MB · Views: 419

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 23:41
Joined
Feb 28, 2001
Messages
22,780
It is possible to put an OnClose or OnUnload event on a form that would be triggered by clicking the "X" control, but the upper-right "X" isn't really an Access object. It is a Windows object. There are ways to control it but you normally have to go through Windows to do it. You cannot actually put an event directly on that button. (At least, not using normal event methods.) Shouldn't be a problem, though, since you can catch the Close and Unload events pretty easily, and they are quite convenient places to perform an action-on-close.

It might be misleading, but OnExit for a form doesn't mean that you clicked the EXIT button - it is that focus is leaving the forum and the form's class module for some other entity. In that context, OnExit is paired with OnEnter.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 00:41
Joined
May 21, 2018
Messages
6,356
Sometimes you have to think "out of the box" like @arnelgp did to get the simple solution. There is no real requirement to change the focus after the close event. The focus can change as soon as you pop open the form, because it is not dependent on anything done in the pop up form. The focus is dependent on the subform. So he simply changes the focus when you open the pop up and not close it.
 

tihmir

Registered User.
Local time
Yesterday, 21:41
Joined
May 1, 2018
Messages
216
check and test
Many, many, many thanks again, @arnelgp. This is really a very simple and smart solution! I had not thought of such a decision - first to change the focus to the Tab and then to open Pop up form! Аbsolutely smart decision!
Sometimes you have to think "out of the box" like @arnelgp did to get the simple solution. There is no real requirement to change the focus after the close event. The focus can change as soon as you pop open the form, because it is not dependent on anything done in the pop up form. The focus is dependent on the subform. So he simply changes the focus when you open the pop up and not close it.
Sometimes really have to think "out of the box". To look for the right, but also practical solution to the problem.
Thank you for your help and advice, @arnelgp, @MajP, @The_Doc_Man!
 

Users who are viewing this thread

Top Bottom