ISelectionSet2 automation Error?

Discussion created by mfancher on Apr 14, 2011
Latest reply on Apr 15, 2011 by Hornbydd
The following code produces an error:

Public Sub Failure()

    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pMxDoc.FocusMap.Layer(0)
    MsgBox pFeatureLayer.Name 'displays correct layer name
    Dim pFeatureSelection As IFeatureSelection
    Set pFeatureSelection = pFeatureLayer
    Dim pSelectionSet As ISelectionSet2
    Set pSelectionSet = pFeatureSelection.SelectionSet
    MsgBox pSelectionSet.Count 'displays correct count
    Dim pFeatureCursor As IFeatureCursor
    pSelectionSet.Update Nothing, True, pFeatureCursor 'this line produces an automation error
    Dim pFeature As IFeature
    Set pFeature = pFeatureCursor.NextFeature
    MsgBox pFeature.Value(2)
End Sub

The exact error message is:

Run-time error '-2147467259 (800040005)':

Automation error
Unspecified error

Any advice on what I'm doing wrong?  I'm working in ArcGIS 9.3.1.