[AccessD] Refering to a control with a variable

Stuart McLachlan stuart at lexacorp.com.pg
Wed May 19 23:57:06 CDT 2010


You're quite correct.

I just use Trim(Str()) automatically whenever I  convert numbers to strings - probably  
because  I do a lot of progamming in PB/Win as well.  In PB/Win "text" & intA  will throw a 
compilation error.

-- 
Stuart


On 20 May 2010 at 0:35, Bill Benson (vbacreations) wrote:

> 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
> 
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 






More information about the AccessD mailing list