Naming form objects with variables

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
 
K

Ken Snell

Try this line in place of yours:

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

rretzko

-----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>




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top