Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to tell which subform has focus 1

Status
Not open for further replies.

egstatus

Programmer
Apr 14, 2005
143
0
0
US
Hi all,
I have a MainForm [Main Page]. This main form has a SubForm [SubformA]. SubformA has 7 subforms [Sections A-G].
I am trying to determine when each of those 3rd level subform(the childs) have focus.

I have tried both lines below on the Form Current Event of the Child(section) subforms:

Code:
[indent]'1)Screen.ActiveForm.Name 'This return the main form name [Main Page][/indent]
[indent]'2)Screen.ActiveForm.ActiveControl.Name 'This return the Second Level form [SubformA][/indent]
    If Screen.ActiveForm.ActiveControl.Name = Me.Name Then
        Forms![Main Page]![SubformA].Form.SectionSelect.value = 1 'if Section A has fucus
        'Forms![Main Page]![SubformA].Form.SectionSelect.value = 2 'if Section B has fucus
    End If

See screen shot below.

My objective here is to make the "Go To Section Toggle button" (see bottom if form) the highlighted button when a particular child form has the focus. So for example if Section "C" has the fucus, I want the button labeled "C" to be the active button at the bottom of the form.

How can I tell which child has the focus?

thanks in advance

Ed

PS I have tried couple of suggestions I found across the net but none of them worked so far.

Untitled_xgxagu.gif
 
Unfortunately you cannot check the active control, because each subform can have an active control even though it may not be highlighted.

So I would make a simple function in a standard module. Something like
Code:
Public Function SubFormFocus(subFrm As String)
  Select Case subFrm
    Case "A"
      'code to select the button
    Case "B"
      'code to select button B
    case C
     ......
 End Select
 
End Function

No on the first subform you use the mouse to select all applicable controls. With the multiple controls selected type into the gotfocus event
=SubFormFocus("A")

do the same on the next subform but type
=subFormFocus("B")

So every time you select a control in the subform it will update the button.
 
Thanks very much.
Great suggestion.
It worked.

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top