ESRISupport12

VBA Problem with Updating user input Selction Set

Discussion created by ESRISupport12 on Nov 10, 2010
Latest reply on Nov 12, 2010 by chump4life
The code below is pieced together from many sources of code found on the forums. I have been working on it longer than I want to admit.  My issue is that it always skips the first selected record of any feature class selection set.  I do not understand enough of the object model to be able to resolve this issue on my own and would appreciate any assistance that can be provided.  I am working with Arc 9.3.1. 

Private Sub UIButtonControl7_Click()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
   
    Dim pUID As New UID
        pUID = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" 'IGeoFeatureLayer IID
   
    Dim pEnumLayer As IEnumLayer
    Set pEnumLayer = pMxDoc.FocusMap.Layers(pUID, True)
        pEnumLayer.Reset
   
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pEnumLayer.Next
   
    Dim pFeatureSelection As IFeatureSelection
    Dim pCursor As ICursor
    Dim pFeatureCursor As IFeatureCursor
    Dim pFeature As IFeature
   
    Dim fValue As String
        fValue = InputBox("Enter Editor Name" & vbNewLine & "Example: ""John Doe"" ")

    Do Until (pFeatureLayer Is Nothing)
        Set pFeatureSelection = pFeatureLayer

        Dim pSelSet As ISelectionSet2
        Set pSelSet = pFeatureSelection.SelectionSet

        If (pFeatureSelection.SelectionSet.Count <> 0) Then
            pSelSet.Update Nothing, True, pFeatureCursor
                Set pFeature = pFeatureCursor.NextFeature

            Do Until (pFeature Is Nothing)
                Dim pCalc As ICalculator
                Set pCalc = New Calculator
                Dim pCalc2 As ICalculator
                Set pCalc2 = New Calculator
                Dim pTable As ITable
                Set pTable = pFeatureLayer.FeatureClass
                Dim pFeatureClass As IFeatureClass
              
            'Field Name Verification
                Dim intFldIndex As Integer
                    intFldIndex = pTable.FindField("EditorName")
                    If intFldIndex = -1 Then
                        MsgBox "PROCESS COMPLETE or Feature Class does not contain a field named EditorName"
                        Exit Sub
                    End If
            'Calculates EditorName
                    Set pCursor = pFeatureCursor
                        With pCalc
                           Set .Cursor = pCursor
                           .Expression = fValue
                           .field = "EditorName"
                        End With
                        pCalc.Calculate
                       
                 Set pFeature = pFeatureCursor.NextFeature
            Loop
          End If
        Set pFeatureLayer = pEnumLayer.Next
    Loop
   
End Sub

Thanks in advance, Jon

Outcomes