Populating variables M1 thru M50 via Eval?

G

Guest

I have a report which displays 50 months data. Each month's slot may have to
be filled in with a given color depending on various date ranges, thus making
a kind of horizontal bar chart. I have set up controls M1 thru M50 for this
purpose. Now I am coding a routine to populate the slots based on the dates.
The problem is I need the variable to be populated to be in a loop i.e.
something like:
For mon = 1 to 50
Eval("M" & mon) = value
Next
Can this be done? I have tried to use Eval before and never been able to get
it to work.
 
M

Marshall Barton

mscertified said:
I have a report which displays 50 months data. Each month's slot may have to
be filled in with a given color depending on various date ranges, thus making
a kind of horizontal bar chart. I have set up controls M1 thru M50 for this
purpose. Now I am coding a routine to populate the slots based on the dates.
The problem is I need the variable to be populated to be in a loop i.e.
something like:
For mon = 1 to 50
Eval("M" & mon) = value
Next


Eval is the wrong thing for this. Use this syntax instead:

Me("M" & mon) = value

which is short for:

Me.Controls("M" & mon) = value

The parenthesis syntax is a standard way to reference an
item in a collection by using a string containing the item's
name.
 

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