By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,960 Members | 2,232 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,960 IT Pros & Developers. It's quick & easy.

VBA Collections Getting Corrupted

P: 43
Has anyone experienced this before? My code is set up and has been working fine, assigning strings, integers and longs, along with other sub-collections to a main Collection. The collection is defined globally and I use it to hold values the application references.

I'm getting the same errors on both Access 2003 and Access 97.

The problem seems to be coming when I assign a member to a collection. If I am in an open form and call a module that does the assignment, under certain conditions it seems to be assigning a whole set of properties from the form I have open instead of the value I am trying to assign.

It does not do it all the time, but it is consistent when I pull attempt to pull certain data into the form.

I've had this happen before a few monthse ago and noticed at that time that it seemed to do it when I was assigning an integer to the collection. I was able to correct it by explicitly using CInt to ensure it was an integer getting assigned.

Why would it assign a set of field properties instead of the intended data?

Here is an example of the code for when the varType = 2 (Integer)
Expand|Select|Wrap|Line Numbers
  1.         col.Add CInt(varValue), strKey
strKey could be "one", for example, and varValue (type Variant) could be 1.
Jun 26 '12 #1
Share this Question
Share on Google+
1 Reply

P: 43
Looks like I've found the problem!

I was checking for just about all varTypes except for two - Nulls and empty strings.

The problem seemed to be occurring when it encountered null values to assign to the collection. I simply changed null values to "" and it took care of it!

Thanks for your interest.
Jun 26 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.