clicking on button in form from subform

Akaban

New member
Local time
Today, 06:43
Joined
Sep 4, 2022
Messages
2
Hi -- I arrived at this thread because I am trying to resolve the "need to click the parent form button twice" problem myself. What I have discovered is

1. When the subform has the focus and you click a button on the parent form -- let's say your own "Undo" button -- the subform's After_Update method fires.
2. From that subform code, if you look at me.parent.activecontrol.name, you get the name of the subform, not the name of the button that was clicked.
3. I have not been able to find any event code in the parent form that executes as a result of clicking the button in the parent while the subform has the focus. Nor have I been able to find a way to even determine that the Parent's UNDO button was clicked.

Like Wysy, I am left for the time being with having to click UNDO twice if the focus was on the subform when UNDO was clicked. I will find a solution, live with two clicks, or implement an UNDO on the child which, in my app, I would want to also undo the parent. Implementing UNDO on the subform with a scope of action outside the subform seems tacky so I likely won't do that.

Bottom line: I'll find the solution or, since the app is for me, I could, if necessary live with double clicks of the UNDO button. I'd rather not though. :)

Update: No sooner did I post the above than I discovered that in the parent form, the subform control's <ctrlName>_Exit method fires. You still don't know what was clicked and the activecontrol remains the subform. But I was wrong to say no code in the parent executes. Now to continue to try and figure out how the code can know UNDO was clicked.

Mod Edit: This topic was split from below original thread to avoid any confusion.
 
Last edited by a moderator:
I just did a quick test and wasn't able to duplicate this problem. As you can see in the image below, the subform is currently being edited. When I click on the "Click Me" button at this stage (while the subform is still in Edit mode), the button's Click event fires. I don't have to click a second time.

1662417233670.png
 
You say "of course" but for some reason the poster thinks that if he presses the "undo" button twice, the subform record is undone and that is simply not happening because it has already been saved. Of course we don't know what code is behind the "undo" button. What we do know is that it is not Me.Undo:)
Hi @Pat Hartman The "undo" button in question was actually just an example from @Akaban, which is not the OP, by the way (@Wysy was).

The original topic of this thread, from what I can see, is that clicking on a button on the main form (it doesn't matter what it does, I just made mine a simple MsgBox call) while the subform is the active control, necessitates a second click, because the OP and Akaban seem to experience a "no action" when they only click on that button once.

So, it seems the topic got sidetracked, somehow. You can do me a favor and either confirm or repudiate my experiment by trying it out yourself and let us know what behavior you got.

Cheers!
 
I was responding specifically to @Akaban 's post where he observed the subform's AfterUpdate event running which of course indicated that the subform record had been saved and therefore was NOT available for "undo" and I also told him to NOT hijack threads in the future because of the confusion it causes. And here we are "confused: :):)

I did add a new button to a main form to see if the behavior had changed. It only took one click to activate the button. I'm pretty sure that there was something else going on in the original post that caused the problem since I've never encountered an issue having to click more than once on a main form button to activate it.
Hi Pat. Thanks for the update and clarification. I don't like it either when I get confused. :)
 
It takes so little these days:eek:. I would have split off the question but I couldn't remember how and I didn't want to mess it up. I thought there was a split option but I couldn't find it. All I saw was a move and I didn't want to move the whole thread since it was in the correct forum.
I think splitting was a good idea. Done! (It took a few steps...)
 

Users who are viewing this thread

Back
Top Bottom