Greetings, I have never seen Access 2007 / VBA do ANYTHING this strange before...
For some reason I see the "active" attribute of a custom class flip stored in a Collection object flip from True to False when the code reaches the next LOC which returns the newly created object instance to the caller.
Looking at the code, I would think that the object is safely stored in the m_PrivateCollection collection object and do not know what to make out of seeing data change within that m_PrivateCollection collection storage object.
The Add method code is as follows:
The LOC marked in RED is where I see the stored object's active value change from True to False in the Watches window. (Yes, within the m_PrivateCollection collection object of the class instance.)
So active = True gets passed in to the Add method, gets assigned to the newItem object, is successfully added to the m_PrivateCollection collection, after which the newItem object becomes the return value of the method and THAT act changes the active value to False within the m_PrivateCollection collection. WHY?!!?!?
And yes, I even went through a decompile / compact / recompile process to make sure that was not the reason for the odd behavior.
For some reason I see the "active" attribute of a custom class flip stored in a Collection object flip from True to False when the code reaches the next LOC which returns the newly created object instance to the caller.
Looking at the code, I would think that the object is safely stored in the m_PrivateCollection collection object and do not know what to make out of seeing data change within that m_PrivateCollection collection storage object.
The Add method code is as follows:
Code:
'Add a new clsObjAdminPickListStandardAQEItem item to the collection
Public Function Add(ByVal intAuthID As Integer, ByVal strAuthUsername As String, ByVal strLogtimestamp As String, ByVal intID As Integer, ByVal intSort As Integer, ByVal boolActive As Boolean, ByVal strTitle As String, ByVal boolAQEFlg As Boolean) As clsObjAdminPickListStandardAQEItem
On Error GoTo Err_Add
Dim newItem As New clsObjAdminPickListStandardAQEItem
Dim Key As Variant
With newItem
.authid = intAuthID
.authusername = strAuthUsername
.logtimestamp = strLogtimestamp
.id = intID
.sort = intSort
.active = boolActive
.title = strTitle
.aqeflg = boolAQEFlg
Key = CStr(.id)
End With
'add to the private collection
m_PrivateCollection.Add newItem, Key
[B][COLOR=Red] Set Add = newItem[/COLOR][/B]
Exit_Add:
Set newItem = Nothing
Exit Function
Err_Add:
Call errorhandler_MsgBox("Class: clsObjAdminPickListStandardAQEItems, Function: Add()")
Add = False
Resume Exit_Add
End Function
So active = True gets passed in to the Add method, gets assigned to the newItem object, is successfully added to the m_PrivateCollection collection, after which the newItem object becomes the return value of the method and THAT act changes the active value to False within the m_PrivateCollection collection. WHY?!!?!?
And yes, I even went through a decompile / compact / recompile process to make sure that was not the reason for the odd behavior.