Link to home
Start Free TrialLog in
Avatar of Not2ruthless
Not2ruthless

asked on

How to identify the name of current subform that's in focus on access form

Hi,
I have a form named frmStudentServiceAndQtrDetails.  On it is a subform named frmsubQtrClassDetails.  
I have a button on the parent form named Help.  I work with blind users, and I'd like them to be able to Alt h to open an input box, informing them exactly what form they are in.  (It is a busy form and would be easy to get lost in.)  My input box works fine except I can seem to get the right syntax to find that we are in the subform.  
Any ideas appreciated.  Thanks!
Avatar of mbizup
mbizup
Flag of Kazakhstan image

If you have a button on your subform, you can use the following code to determine the name of the subform that the button is on:

MsgBox Me.ActiveControl.Parent.Name


<I have a button on the parent form named Help.>
The trouble I see with this approach is that if a user is editing subform data and clicks a button on the main form to determine which subform they were editing, they are no longer in the subform - but back in the main form. (so the answer to the question "where am I" when clicking a button on the main form would always be "the main form")
Avatar of Not2ruthless
Not2ruthless

ASKER

Thanks.  The Button itself is on the main form.  I'd like to use that same help button to determine what form (the main or sub), that I'm in.  If it's not possible, I could put two help buttons but would like to avoid it
Ruth.  
<< to determine what form (the main or sub), that I'm in >>

That's the problem right there... as soon as you click a main form button you are in the main form, regardless of whether you were in the main or sub form before clicking the button.



Just for kicks, is there any syntax at all to determine the name of the subform one is in at any given time?  (Pretending I don't have a Help Button that would divert focus).  Now I'm just curious :)
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are using KeyPreview and the KeyDown event to test for Alt_H, then you really don't have a problem.
Fyed, the previous control did the trick.  I work with totally blind users, but like to make it user friendly for us photo-dependents as well!!

Thanks mBizup and Fyed!!
I've requested that this question be closed as follows:

Accepted answer: 0 points for Not2ruthless's comment http:/Q_27316697.html#36564547

for the following reason:

Didn't mean to use my comment as the solution, sorry!
I accidently added a comment before accepting solution by Fyed.  Would like to retract that and Accept Fyed's solution.
So am objecting to my own non-solution :)
fyed,

<< Screen.PreviousControl.Name >>

Nice trick!  

I was envisioning some convoluted method of determining the user's "last location" by using global variables.

It makes sense that there is a "PreviousControl" for this type of need...

I learned something new :)


Ruth,

<So am objecting to my own non-solution :) >

Your objection cancelled the pending closure which was marking your answer as accepted... the button you need to accept fyed's solution should be visible to you again.