I'm not sure if someone will be able to help me here but I'm tearing my hair out so just trying to see if someone else can see the trees (the wood is restricting my vision of them it seems).
Problem is though, the full code is huge (and all working as expected) except for what's going on in this subroutine, I can't post the full thing due to company sensitive data. So I'll explain the issue drop the bit of code where the issue is happening and see if anyone can spot where I'm going wrong. Appreciate this may be difficult though given the limited amount I can put up of a much larger application.
So here is the code in question:
'Moves the data extracted from DB2 into the output/calculation template object
Private Sub TemplatePriceDataImport(ByRef colRegionalOutputTemplate As Collection, ByRef strCountry As String)
Dim clsRegionalData As Level3_RegionalExtractedData
Dim clsFundExtract As Level4_RegionalFundExtract
Dim clsPriceExtract As Level5_RegionalPricesExtract
Dim clsFundOutput As Level3_RegionalFundOutput
Dim clsPriceOutput As Level4_RegionalPriceOuput
Set clsRegionalData = GetRegionalData(strCountry)
For Each clsFundOutput In colRegionalOutputTemplate
Set clsFundExtract = clsRegionalData.FundCollection.Item(clsFundOutput.FundCode & clsFundOutput.FundSeries)
For Each clsPriceOutput In clsFundOutput.DateLevelCollection
Set clsPriceExtract = clsFundExtract.PricesCollection.Item(clsPriceOutput.EffectiveDate)
clsPriceOutput.Actual6DPUnsmoothed = clsPriceExtract.Unsmoothed6dp
clsPriceOutput.Actual1DPUnsmoothedBid = clsPriceExtract.Unsmoothed1dpBid
clsPriceOutput.Actual1DPUnsmoothedOffer = clsPriceExtract.Unsmoothed1dpOffer
clsPriceOutput.Actual6DPSmoothed = clsPriceExtract.Smoothed6dp
clsPriceOutput.Actual1DPSmoothedBid = clsPriceExtract.Smoothed1dpBid
clsPriceOutput.Actual1DPSmoothedOffer = clsPriceExtract.Smoothed1dpOffer
clsPriceOutput.DailyUnsmoothedDeduction = GetDailyUnsmoothedDeduction(clsRegionalData, clsFundOutput.FundCode, clsFundOutput.FundSeries, clsPriceOutput.EffectiveDate)
If Not clsPriceOutput.SectorLevelData Is Nothing Then Call TemplateSectorDataImport(clsFundOutput, clsPriceOutput)
Next clsPriceOutput
Next clsFundOutput
End Sub
Display More
So essentially what is happening is that earlier I collected a load of data through various SQL calls, the data is held at the date that applies from and is then superseded by any data held at a later date.
Where the output template that it is being passed to is holding data on a daily basis. So I'm trying to create a template where all the daily data is held daily (obviously) like the prices, but then any data that is held over a range greater than a day is output to the daily template this is to make the subsequent calculations that will be coming easier to perform in a loop as all the data needed in each instance of the class should be held within it (without having to call it based on different keys from a number of different levels in the hierarchy of Classes/Collections.
I am expecting the outer for loop to pass through each Fund/Fund Series which it appears to be doing. On moving through each Fund/Fund Series instance of the Level3_RegionalFundOutput Class I set an instance of the clsFundExtract object (which is an instance of the Level4_RegionalFundExract class, which holds the data extracted from the DB2 tables).
So far so good.
The next for loop should be moving through each of the dates in the range for the current Level3_RegionalFundOutput which clsFundOutput is representing. So Level3_RegionalFundOutput class contains a collection of Level4_RegionalPriceOutput class objects. Which hold prices (and some other stuff) which is differentiated by date.
Same idea as the previous loop, I set the clsPriceExtract class as the appropriate instance of Level5_RegionalPricesExtract.
Within that loop the data extracted from the DB2 tables (Level5_RegionalPricesExtract) is passed into the Level4_RegionalPriceOutput class.
However, when that data is being passed from the extract class to the output class it's passing it to every instance of the price output class for all funds in the colRegionalOutputTemplate.
Hopefully that makes sense, I can try and pass in a worked example if that would help further.