[AccessD] Refering to a control with a variable

Bill Benson (vbacreations) vbacreations at gmail.com
Wed May 19 23:35:08 CDT 2010


Controls("txtbox" & IntA)   for simplicity ?

If the intA is properly declared as integer I don't see the need for Str()
- which requires trimming, as you noted ... or even Cstr (which doesn't).


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan
Sent: Wednesday, May 19, 2010 11:24 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Refering to a control with a variable

You can actually get away with just:

Controls("txtbox" & Trim(Str(IntA)))

-- 
Stuart

On 20 May 2010 at 13:15, Stuart McLachlan wrote:

> Me.Controls.Item("txtbox" & Trim(Str(IntA)))
> 
> (the "Me." is optional)
> 
> -- 
> Stuart
> 
> 
> On 19 May 2010 at 19:17, Dale_Anne Kalsow wrote:
> 
> > Good Evening,   If I have a control named txtbox1 and a variable of intA
> > with a value of 1, does anyone know how to refer to the control in VBA
> > with with something simular to "txtbox" & intA?   Thanks!   Dale 
> > 
> > 
> >       
> > -- 
> > 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
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.819 / Virus Database: 271.1.1/2883 - Release Date: 05/19/10
14:26:00






More information about the AccessD mailing list