codequest
asked on
Detect which subform is active
In Access 2003, I have a form Main that is a holder for several subforms, including Action and Task. (They aren't linked to the MAIN form, it's just a shell/holder. I have these subforms on fixed positions on the Main form instead of floating for various reasons that are *currently* more important that the feature I'm asking about here).
I would like to be able to set a global string variable TaskOrAction to either "Task" or "Action" when that respective subform is activated.
I need to find an event that I can use to detect that the subform is activated, or, more specifically, if ANY control on that subform is used, so I can set the value of TaskOrAction (which I use later to inform a query of whether to look for a key value in ...Task or Action).
I tried a few things that didn't work:
1) According to MS, "Activate" does not work for subforms,
2) According to this, http://www.access-programmers.co.uk/forums/showthread.php?t=191507
GotFocus does not work unless you use the record selector (though I did not see that happen either, when I tried GotFocus
3) Enter only works for specific controls, and I need to set the variable if any control on the subform is used, or if the subform record selector is keyed.
I built a little test bed, attached.
Any suggestions on this would be appreciated.
Thanks!
Test.mdb
I would like to be able to set a global string variable TaskOrAction to either "Task" or "Action" when that respective subform is activated.
I need to find an event that I can use to detect that the subform is activated, or, more specifically, if ANY control on that subform is used, so I can set the value of TaskOrAction (which I use later to inform a query of whether to look for a key value in ...Task or Action).
I tried a few things that didn't work:
1) According to MS, "Activate" does not work for subforms,
2) According to this, http://www.access-programmers.co.uk/forums/showthread.php?t=191507
GotFocus does not work unless you use the record selector (though I did not see that happen either, when I tried GotFocus
3) Enter only works for specific controls, and I need to set the variable if any control on the subform is used, or if the subform record selector is keyed.
I built a little test bed, attached.
Any suggestions on this would be appreciated.
Thanks!
Test.mdb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"1) According to MS, "Activate" does not work for subforms, "
That is correct.
We are basically using
Screen.ActiveForm.ActiveCo ntrol.Parent.Name
keeping in mind that a subform IS a Control ... a container for an actual Form - to be used as a subform.
mx
That is correct.
We are basically using
Screen.ActiveForm.ActiveCo
keeping in mind that a subform IS a Control ... a container for an actual Form - to be used as a subform.
mx
ASKER
Works slick. Thanks!
mx
Test-MX01.mdb