VBA Collections Getting Corrupted

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sedrick
    New Member
    • Aug 2011
    • 43

    VBA Collections Getting Corrupted

    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)
    Code:
            col.Add CInt(varValue), strKey
    strKey could be "one", for example, and varValue (type Variant) could be 1.
  • Sedrick
    New Member
    • Aug 2011
    • 43

    #2
    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.

    Comment

    Working...