Naming form objects with variables

  • Thread starter Thread starter rretzko
  • Start date Start date
R

rretzko

I have created an array to hold values that will be used
as label object captions. For example, array(1,1)=100445,
array(1,2)=234879. I want to use the value in array(1,1)
for a caption in lblCell11, the value in array(1,2) for a
caption in lblCell12, etc.

I want to use a formula such as:

for counter01 = 1 to someNbr
for counter02 = 1 to someOtherNbr
if array(someNbr,someOtherNbr) > 0 then
me."lblCell"&someNbr&someOtherNbr.Caption = array
(someNbr,SomeOtherNbr)
End if
Next
Next

However, VBA doesn't seem to want to work like this. Any
hints/suggestions on how I can do this (or get around it)
are appreciated!

Rick
 
Try this line in place of yours:

if array(someNbr,someOtherNbr) > 0 then
me.Controls("lblCell" & someNbr & someOtherNbr).Caption = array
(someNbr,SomeOtherNbr)
 
-----Original Message-----
Try this line in place of yours:

if array(someNbr,someOtherNbr) > 0 then
me.Controls("lblCell" & someNbr & someOtherNbr).Caption = array
(someNbr,SomeOtherNbr)

--
Ken Snell
<MS ACCESS MVP>




.
 
Back
Top