Invalid Procedure Call in IDataStatistics.Statistics

Discussion created by smalcolm on Apr 29, 2011
Latest reply on Apr 29, 2011 by smalcolm

I have some VBA code that worked fine in 9.3.1. My agency just upgraded to 10.0, and the code seems to work fine up to a call to IDataStatistics.Statistics. I do not recall seeing this on the deprecated functions list. The code (below) is a boilerplate for extracting max and min from a field. Any help (or suggestions for alternative coding) would be greatly appreciated!


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)
    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 (ERROR APPEARS HERE)  
    Zmax = pStatResults.Maximum
    Zmin = pStatResults.Minimum

End Sub