[AccessD] A2K: Get Control's Label Name

Andy Lacey andy at minstersystems.co.uk
Fri Jun 11 01:41:54 CDT 2004


Hey Darren, how're you going?

You can do it in a backwards sort of way. Every label's parent is its
control (if it has one). So if you know the text control you're looking for
you can iterate through the labels until you hit it. Like this:

Function GetLabelName(frm As Form, ctl As Control)
Dim ctlLabel As Control
For Each ctlLabel In frm.Controls
  If ctlLabel.ControlType = acLabel Then
    If ctlLabel.Parent.Name = ctl.Name Then
      GetLabelName = ctlLabel.Name
    End If
  End If
Next
End Function

SYWWE

-- Andy Lacey
http://www.minstersystems.co.uk 




> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com 
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darren DICK
> Sent: 11 June 2004 07:19
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] A2K: Get Control's Label Name
> 
> 
> Thanks Bob
> The naming convention I am using is different to that
> We are using "lbl" and then the control name
> I am not even directly referring to the 'Parent control' either. 
> I am using TAGs that meet a criteria.
> I was hoping it was an exposed property of some kind
> 
> DD
> 
> ----- Original Message ----- 
> From: "Bob Gajewski" <rbgajewski at adelphia.net>
> To: "Access Developers discussion and problem solving" 
> <accessd at databaseadvisors.com>
> Sent: Friday, June 11, 2004 3:51 PM
> Subject: RE: [AccessD] A2K: Get Control's Label Name
> 
> 
> > Darren
> > 
> > I believe that the default label name is FieldName_Label, 
> so you can 
> > always just append the _Label to your field names for 
> handling (eg: if 
> > the field name is txtMyTextBox then the label's caption should be 
> > Me.txtMyTextBox_Label.caption).
> > 
> > Regards,
> > 
> > Bob Gajewski
> > 
> > 
> > -----Original Message-----
> > From: accessd-bounces at databaseadvisors.com
> > [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of 
> Darren DICK
> > Sent: Friday, June 11, 2004 01:37
> > To: Access Developers discussion and problem solving
> > Subject: Re: [AccessD] A2K: Get Control's Label Name
> > 
> > 
> > Yeah I do that too
> > but in this case I can't because things are being done differently 
> > using tags
> > 
> > Many thanks
> > 
> > DD
> > 
> > 
> > ----- Original Message -----
> > From: "Christopher Hawkins" <clh at christopherhawkins.com>
> > To: <accessd at databaseadvisors.com>
> > Sent: Friday, June 11, 2004 2:27 PM
> > Subject: RE: [AccessD] A2K: Get Control's Label Name
> > 
> > 
> > > I may be doing it the hard way, but I've always named my labels 
> > > 'lbl' & ControlName.
> > >
> > > -C-
> > >
> > > ---- Original Message ----
> > > From: d.dick at uws.edu.au
> > > To: AccessD at databaseadvisors.com,
> > > Subject: RE: [AccessD] A2K: Get Control's Label Name
> > > Date: Fri, 11 Jun 2004 14:16:57 +1000
> > >
> > > >Hello all
> > > >When I drop a control onto a form (say a text Box)
> > > >The system usually it something like Text0 or text1 etc 
> and it also 
> > > >creates its very own label with similar names.
> > > >
> > > >If I know the name of a control can I get it's label name and or 
> > > >caption or any such properties?
> > > >
> > > >eg Me.txtMyTextBox.ChildLabel.caption
> > > >
> > > >Many thanks in advance
> > > >
> > > >Darren
> > > >
> > > >--
> > > >_______________________________________________
> > > >AccessD mailing list
> > > >AccessD at databaseadvisors.com 
> > > >http://databaseadvisors.com/mailman/listinfo/accessd
> > > >Website: http://www.databaseadvisors.com
> > > >
> > >
> > >
> > > --
> > > _______________________________________________
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com 
> > > http://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > --
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com 
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> > 
> > 
> > --
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> -- 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com 
> http://databaseadvisors.com/mailman/listinfo/a> ccessd
> Website: 
> http://www.databaseadvisors.com
> 
> 




More information about the AccessD mailing list