Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / February 2006

Tip: Looking for answers? Try searching our database.

Does associative array exist in VBA?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jose.cortijo@gmail.com - 13 Feb 2006 09:01 GMT
Hi everybody,

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

Jose
Wayne Morgan - 13 Feb 2006 14:01 GMT
If you're doing what I thing you're doing, try this syntax:

Me.Controls("tot" & pParam)

Signature

Wayne Morgan
MS Access MVP

> Hi everybody,
>
[quoted text clipped - 18 lines]
>
> Jose
YaKs - 14 Feb 2006 10:01 GMT
Hi Wayne,

I was mistaken, I am trying to that but not in Access, it is in Excel.

The sintax you said doesn't work either.

Should I try another one?

Thanks once again.
Wayne Morgan - 14 Feb 2006 11:08 GMT
Well, the syntax I gave didn't work because you're really using Excel.
Please try the Excel newsgroup, they'll be able to help you better.

Signature

Wayne Morgan
MS Access MVP

> Hi Wayne,
>
[quoted text clipped - 5 lines]
>
> Thanks once again.
David W. Fenton - 13 Feb 2006 20:37 GMT
> I would like to access to one variable by an indirect mode. I
> would try to explain myself:
[quoted text clipped - 14 lines]
>
> 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.

Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

YaKs - 14 Feb 2006 09:11 GMT
Hi David,

I was mistaken, I am trying to that but not in Access, it is in Excel.

The sintax you said doesn't work either.

Should I try another one?

Thanks once again.
YaKs - 14 Feb 2006 09:20 GMT
One thing I forgot, I tried to acces not to a control, it is just a
global variable.

I already changed the program but I would like to know if it is
possible to do that thing.

Thank you very much

Cheers!
David W. Fenton - 14 Feb 2006 21:00 GMT
> Hi David,
>
[quoted text clipped - 4 lines]
>
> Should I try another one?

Post your question in an Excel group.

In any event, I expect that if you're trying to concatenate a
variable name you need to use Eval().

But my guess is that you need to completely change your approach to
the problem. In Access, I would suggest a custom collection or an
array, but I don't know what Excel's variety of VBA supports.

Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.