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.
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.
clicking on button in form from subform
Hi, I am trying to solve the following problem: Object is a form/subform one. The header of the form has command button. If the focus is on the subform for entering data and i want to click the command button in the parent form, i need to click twice. I suppose once to move the focus from...
www.access-programmers.co.uk
Last edited by a moderator: