CSV join not recognized in VBA code

Discussion created by smalcolm on May 3, 2011
I am using VBA in 9.3.1.

I have a shapefile to which I manually join a csv file. The join works fine and when the table is opened all fields are present and accounted for.

However, when I try to gather statistics on the fields, it appears that all the join is not present. In the code below, the FieldCount is only 5 (the number in the original shapefile). This causes an error in the call to pStatResults.

I should note that this code worked a few weeks ago, and I have not modified it. Our Agency did upgrade to 10.0, and I moved back to 9.3 (but perhaps with different environment variables, references, etc) to make sure it wasn't an issue with 10.0. It's possible (likely?) that I have forgotten an important step when setting up the join, but I am at a loss. Thanks for any input!

Sub FindFieldExtremes(FieldName, LayerIndex, Zmax, Zmin)
    Dim pMxDoc As IMxDocument
    Dim pFLayer As IFeatureLayer
    Dim pData As IDataStatistics
    Dim pCursor As ICursor
    Dim pStatResults As IStatisticsResults
    Set pMxDoc = ThisDocument
    Set pFLayer = pMxDoc.FocusMap.Layer(LayerIndex)
    q = pFLayer.FeatureClass.Fields.FieldCount
    Set pCursor = Nothing
    Set pCursor = pFLayer.Search(Nothing, False)
    Set pData = New DataStatistics
    Set pData.Cursor = pCursor
    pData.Field = FieldName
    Set pCursor = pFLayer.Search(Nothing, False)
    Set pData.Cursor = pCursor
    Set pStatResults = pData.Statistics
    Zmax = pStatResults.Maximum
    Zmin = pStatResults.Minimum

End Sub