jo**********@gmail.com wrote in
news:11**********************@o13g2000cwo.googlegr oups.com:
I would like to access to one variable by an indirect mode. I
would try to explain myself:
I have like twelve variables and all of them are global scope.
The point is that I have a private method that depending of the
value of one of its params I have to access to one global variable
or other one.
I tried to access like
Me.["tot"+pParam]
but it doesnt work.
is it possible to do this in other way? or maybe it is impossible
in VBA...
Thanks very much in advance
Sounds like you've used naming conventions for controls using
numbers.
Your mistake is in using the wrong method for concatenating the
name. What you want is:
Me("tot" & pParam)
You'd use the & concatenation operator because you don't want to
propagate Nulls (the + concatenation operator propagates Nulls, so
that if pParam is Null (assuming it's a Variant and can be Null),
then you'd be passing Me(Null) which will generate an error.
Me("tot") will also generate an error if there's no control of that
name, but probably a less serious error).
I'm not at all sure what this has to do with arrays, though.
Also, It sounds like you're populating repeating data, which sounds
like a possible design error somewhere along the way. Now, I've done
exactly what you're describing in particular situations, but it's
something of a kludge, in my opinion, as it ties your code to
objects on a form having been named in a particular fashion.
--
David W. Fenton
http://www.dfenton.com/
usenet at dfenton dot com
http://www.dfenton.com/DFA/