Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $95

Control addressing on subforms

Discussion in 'Information Technology' started by JB, Nov 12, 2005.

  1. JB

    JB
    Expand Collapse
    Guest

    I have a subform that contains a bunch of controls (aka color-coded boxes)
    that I want to be able to assign OnDblClick actions to. Other data defines
    color/position of my boxes, but I need to programmaticlly modify what happens
    during the OnDblClick of each box.

    Ideally, I wanted to write 1 macro that I can assign to the control(s) as
    VBA is rearanging the subform. The problem I am having is:

    How can I get the Control Name off of the sub-form? I have tried versions of:
    CurrentObjectName = Application.CurrentObjectName and
    Set ctl = Screen.ActiveControl

    but I keep getting pointed to the main form not the subform. Any
    suggestions on how to tell which control has been clicked on?


    Thanks in advance.
     
  2. Loading...

    Similar Threads Forum Date
    How To Control The 5 Thieves? Questions and Answers Apr 7, 2016
    General Controlling Kaam (Lust) Hard Talk Apr 8, 2014
    USA Sikh Americans join Barack Obama in urging lawmakers on Gun Control Breaking News Mar 29, 2013
    Controversial SGPC Takes Control of Live Telecast at Bangla Sahib Hard Talk Feb 7, 2013
    USA Sikhs Join Gun Control Debate. Meet with Vice President Biden Breaking News Jan 16, 2013

  3. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    Use Form.ActiveControl instead of Screen.ActiveControl.

    Pass a reference to the subform into your generic procedure.

    Example:
    Function DoSomething(frm As Form)
    Debug.Print "You dbl-clicked " & frm.ActiveControl.Name
    End Function

    Call it by setting the text box's On DblClick property to:
    =DoSomething([Form])
    or if you prefer to use an event procedure:
    Private Sub Text1_DblClick(Cancel As Integer)
    Call DoSomething(Me)
    End Sub

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "JB" <JB@discussions.microsoft.com> wrote in message
    news:69FFE5CA-5569-4197-9356-E9A995A79C93@microsoft.com...
    >I have a subform that contains a bunch of controls (aka color-coded boxes)
    > that I want to be able to assign OnDblClick actions to. Other data
    > defines
    > color/position of my boxes, but I need to programmaticlly modify what
    > happens
    > during the OnDblClick of each box.
    >
    > Ideally, I wanted to write 1 macro that I can assign to the control(s) as
    > VBA is rearanging the subform. The problem I am having is:
    >
    > How can I get the Control Name off of the sub-form? I have tried versions
    > of:
    > CurrentObjectName = Application.CurrentObjectName and
    > Set ctl = Screen.ActiveControl
    >
    > but I keep getting pointed to the main form not the subform. Any
    > suggestions on how to tell which control has been clicked on?
    >
    >
    > Thanks in advance.
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page