I would like to edit a selected feature/record via ArcMap vba, but I'm not having much luck with this code sample (see code below). I'm not getting an error, but the record selected is not updating.
Private Sub Update_Click()
Dim pMxDoc As IMxDocument
Dim pLayer As ILayer
Dim pInFtrLyr As IFeatureLayer
Dim pFtrSel As IFeatureSelection
Dim pFeatureClass As IFeatureClass
Dim pFields As IFields
'Dim ii As Integer
Dim pPoint As IPoint
'Dim pSegColl As ISegmentCollection
Dim pEnumLayer As IEnumLayer
Dim pMap As IMap
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap
Set pEnumLayer = pMap.Layers
Set pLayer = pEnumLayer.Next
Do Until pLayer Is Nothing
If pLayer.Name = "Copy of Wells_test" Then
Set pInFtrLyr = pLayer
End If
Set pLayer = pEnumLayer.Next
Loop
Set pFtrSel = pInFtrLyr
If pFtrSel.SelectionSet.Count = 0 Then
MsgBox "Please select one Well record", vbOKOnly
Exit Sub
ElseIf pFtrSel.SelectionSet.Count > 1 Then
MsgBox "Please select one Well record", vbOKOnly
Exit Sub
Else
If pFtrSel.SelectionSet.Count = 1 Then
Set pPoint = pInFtrLyr.FeatureClass.GetFeature(pFtrSel.Selectio nSet.IDs.Next).Shape
End If
End If
Set pFeatureClass = pInFtrLyr.FeatureClass
Dim pFSelection As IFeatureSelection
Set pFSelection = pInFtrLyr
Dim pFClass As IFeatureClass
Set pFClass = pInFtrLyr.FeatureClass
Dim pFCursor As IFeatureCursor
Set pFCursor = pFClass.Update(Nothing, True)
Dim pID As New esriSystem.UID
pID.value = "esriEditor.Editor"
Dim pEditor As IEditor
Set pEditor = Application.FindExtensionByCLSID(pID)
Dim pFeature As esriGeoDatabase.IFeature
Dim pEnumFeature As esriGeoDatabase.IEnumFeature
Set pEnumFeature = pEditor.EditSelection
Set pFeature = pEnumFeature.Next
Do Until pFeature Is Nothing
pFeature.value(pFeature.Fields.FindField("Type")) = "update"
Set pFeature = pEnumFeature.Next
Loop
End Sub