Invalid Procedure Call in IDataStatistics.Statistics

411
1
04-29-2011 08:13 AM
ScottMalcolm
New Contributor
Hello,

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!

Scott

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
0 Kudos
1 Reply
ScottMalcolm
New Contributor
I have discovered a problem earlier that is likely the cause of this error. I will work on it a bit before starting a new thread.

Thanks for the forum!
0 Kudos