Let property changing all values in Class module

J

J Streger

I have a three tiered Class modules Set up:

clsEVM contains a collection of clsMonths which contains a collection of
clsWBSIDs

In the clsEVM and clsMonths classes, I use the following to set the
underlying classes:

'Set the entire WBSID collection
Property Set WBSIDs(S As Collection)
Set pWBSID = S
End Property

'Get the entire WBSID collection
Property Get WBSIDs() As Collection
Set WBSIDs = pWBSID
End Property

'Get a specific WBSID entry
Public Function WBSID(index As Variant) As clsWBSID
'If numeric, decalre based off index
If IsNumeric(index) Then
If index > pWBSID.Count Or index < 1 Then
Err.Raise 9
Else
Set WBSID = pWBSID(index)
End If
Else

Dim WP As clsWBSID
'If string, find appropriate value in collection
For Each WP In pWBSID
If UCase(WP.ChargeCode) = UCase(index) Then
Set WBSID = WP
Exit For
End If
Next

End If
End Function

My problem is that when I use the line:

Me.Month(iMonth).WBSID(sWBSID).ACWP = 5

in the clsEVM module, no matter what imonth is, all instances of sWBSID
found in any particular iMonth are made equal to 5, instead of just the 1
instance in iMonth. So if I have 3 months, and iMonth is = 1, sWBSID for
iMonth = 1, iMonth = 2, and iMonth = 3 will become 5 and I just want iMonth =
1 to equal 5. I can set an object to represent the individual Month in the
class to avoid the confusion, but I thought that was a bit redundant. Thanks
for any help on this. (I searched the MSDN and Chip's site to no avail)
 
T

Tim

Just a guess but have you tried:

Me.Month.Item(iMonth).WBSID(sWBSID).ACWP = 5

(assuming it's a collection)
You don't show any code related to the "Month" property - that would help.

Tim
 
J

J Streger

The code to declare months in the clsEVM is:

Property Set Months(S As Collection)
Set pMonth = S
End Property

Property Get Months() As Collection
Set Months = pMonth
End Property

Public Function Month(index As Integer) As clsMonth

If index > pMonth.Count Or index < 1 Then
Err.Raise 9
Else
Set Month = pMonth(index)
End If

End Function

Months are only numbered so I don't need to index them by a string value.

As you can see my evm.Month function should return single month, but somehow
even though I return a single month, I affect all months equally.
--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top