Pamela-
When you said "associated," both Crystal and I thought you meant a label
attached to the text box. Typically, if you drag a text box onto a form in
Design view, Access also creates an "associated" label. In fact, that Label
control will have a Parent property that points to the control with which it is
associated.
It sounds like you have independent labels. In that case, you could put in the
Tag property of the label the name of the control with which it is "associated."
You could then use the Tag property in the Click event of the Label control to
determine which field needs to be sorted.
John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Pamela Zimmerman
Sent: Tuesday, May 31, 2011 5:54 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] get control name associated with label
Thanks John and Crystal!
I will add a bit. I have a series of forms that display a large amount of
reference table data. Clients need to maintain tables using these forms,
add new, or edit existing records. I have a client that has a large amount
of reference table data. They have requested the ability to sort the data
on various fields by clicking the column headings (which are labels).
The forms are continuous forms with the label in the top section of the form
and the data below in a column, similar in appearance to an excel
spreadsheet. Each form has several columns. It seems intuitive for the
user to click the column heading to sort the data as needed, not as much so
to click the column of data.
Although I could code the click from label using the control name, I don't
especially want to, because I will have to have this in a hundred or so
places and it will be more efficient if I can paste the same thing rather
than edit all of the individual control names in the code.
Crystal, I'm not quite tracking on the notion that a label associated with a
control has no events. I have click event code attached to lblPodNumber
(which is associated with txtPodNumber) and it runs as it is coded (just not
as I want it to).I must be misunderstanding something here.it's getting
late.
All I really want, is on the click of the label, move the focus to that
label's associated control. This would then make the desired control the
active control, and then the code would work. Is this possible??
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Crystal
Sent: Friday, May 27, 2011 2:15 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] get control name associated with label
Hi Pam,
adding on to what John said ...
if a label is associated with a textbox or other control, it has no events.
The only way it can have events is to NOT be associated.
> I need to reference the name of the control that the label
> is associated
> with, not the active control.
you can reference a control this way:
Me.controlname
or
Me("controlname")
~~~
looking at your code:
Call thisOrder(ActiveControl.Name, Screen.ActiveForm)
instead of using the name property of the ActiveControl, which won't be
right, why not pass the name of the control you wish.
'~~~~~~~~~~~
Call thisOrder("txtPodNumber", Me)
'~~~~~~~~~~~
Maybe use ME instead of Screen.ActiveForm unless you are on a subform and
want to refer to a parent
I would caution against embedding logic into controls, but another thing you
can do is use the TAG property, which is the last property on the Other tab
of the property sheet. It is not used by Access, you can write and read to
it as you wish. This means, you could put the name of the control there and
do this:
'~~~~~~~~~~~
'not recommended
Call thisOrder(ActiveControl.tag, Me)
'~~~~~~~~~~~
It is better to put the logic in the the code behind the form where you can
compile and fix things quicker.
Warm Regards,
Crystal
*
(: have an awesome day :)
*
--- On Fri, 5/27/11, John Viescas wrote:
> Pam-
>
> Don't put the Click event procedure in the label - put it
> in the associated text
> box. If the user clicks the associated label, the
> click event for the text box
> fires!
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
>
> -----Original Message-----
> From: Pamela Zimmerman
> Can anyone one tell me how I can reference a control
> associated with a
> label?
>
>
>
> Given the form has a label called lblPodNumber and a field
> called
> txtPodNumber
>
>
>
> I have this:
>
>
>
> Private Sub lblPodNumber_Click()
>
>
>
> Call thisOrder(ActiveControl.Name, Screen.ActiveForm)
>
>
>
> End Sub
>
>
>
> I need to reference the name of the control that the label
> is associated
> with, not the active control. How can I do that?
>
>
>
> If possible, I would prefer not to use the actual label
> name (lblPodNumber),
> as I would like to keep this as reusable as possible.
>
>
>
>
> Suggestions appreciated!
>
>
>
> Pam
>
>
>
[Non-text portions of this message have been removed]
------------------------------------
Yahoo! Groups Links
Selasa, 31 Mei 2011
RE: [MS_AccessPros] get control name associated with label
__._,_.___
MARKETPLACE
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar