Another form's button to activate. (1 Viewer)

Alex Motilal

New member
Local time
Today, 14:33
Joined
Jul 7, 2021
Messages
15
Hi all.
I have a form and on clicking a button another form will pop up to enter data. On clicking the Close button of the Pop Up form, the Update Button of the original form should activate (that is should act as if the button clicked).
Is it possible? If so please help me with the code.
Thanks.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 02:03
Joined
Aug 30, 2003
Messages
36,118
Change the button's code from Private to Public and then in the second form

Forms!FirstFormName.ButtonName_Click()
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:03
Joined
May 7, 2009
Messages
19,170
you need to make the Click event of the button Public instead of private
before you can call it.
 

Alex Motilal

New member
Local time
Today, 14:33
Joined
Jul 7, 2021
Messages
15
you need to make the Click event of the button Public instead of private
before you can call it.
Can you elaborate please. The second form's Close Button Event:
Code:
Private Sub Command10_Click()
On Error GoTo Command10_Click_Err

    DoCmd.Close , ""

Command10_Click_Exit:
    Exit Sub

Command10_Click_Err:
    MsgBox Error$
    Resume Command10_Click_Exit

End Sub
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:03
Joined
May 21, 2018
Messages
8,463
you can make this a little more seamless and less tightly coupled.

From the calling form if you open the form ACDIALOG in the windowmode, code execution will stop and then resume when the pop up closes

Code:
docmd.openform "popup form name",,, ACDIALOG
'Now run your code which will run after the popup closes
Your button_Click name here
also verify my commas. I believe it is the 4th argument.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:03
Joined
May 7, 2009
Messages
19,170
not the pop-up form, the first form.
see this demo.
 

Attachments

  • activate_button.accdb
    408 KB · Views: 145

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:03
Joined
Feb 19, 2002
Messages
42,981
On clicking the Close button of the Pop Up form, the Update Button of the original form should activate (that is should act as if the button clicked).
The request is illogical. If the calling form is dirty, it's BeforeUpdate event will run automatically. If the form is not dirty, then in theory, pressing your update button will not do anything.

If you want code to run after the popup form is finished, open the popup as a dialog. That suspends code running in your procedure. When the popup closes, control returns to the next line in your code so you can run the button code directly.
 

Users who are viewing this thread

Top Bottom