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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining a labels name when dblclicked 6

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
US
Have a form that has 40 entries of a label and a text box with each label. When a label is double clicked in need to get the name of the lable in vba. I have tried this:

Private Sub Bay01_DblClick(Cancel As Integer)
EventSwitch = True
Dim fromCtl As String
fromCtl = Me.ActiveControl.Name

DoCmd.OpenForm "BaysFilled", , , , , , OpenArgs = fromCtl 'Pass name to dialogue box

EventSwitch = False
End Sub


This gives me the name of the textbox, not the name of the label, which is what I need to write the code in the dialogue box..
The name is text and is passed as text via OpenArgs.
EventSwich is a Boolian variable in a standard module.

Thanks in advance



jpl

 
another bit of information. In pondering MajP,s solution I thought I would try using an event on the textbox to get the name of the lable for the connected textbox, since I couldn't click the label. and, it worked. So the statement lblname =[Me].[ActiveControl].[Controls](0).[Name] does return the name of the label.

jpl
 
Just a minor clarification that may not be apparant from this thread: MajP's technique does not extend to other Office Applications, as Access forms and controls differ, often significantly, from the forms and controls from the Forms 2 library used by other VBA hosts.
 
...which was the purpose of my first post on 16 Nov

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
strongm said:
Just a minor clarification that may not be apparant from this thread: MajP's technique does not extend to other Office Applications, as Access forms and controls differ, often significantly, from the forms and controls from the Forms 2 library used by other VBA hosts
Yes with MS Forms you have the ability to do this by making control arrays but not in Access. This is a shortcoming in Access. Instead in Access you have the ability to assign a function to controls events. This is not the same as writing an event procedure. This was the basis of my original statement of that I never understood why MS designed it this way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top