hsiddique

ArcMap not detecting pEditor.HasEdits! (VBA)

Discussion created by hsiddique on Dec 16, 2011
Latest reply on Dec 16, 2011 by hsiddique
Hi all,

I have a button that will delete a selected feature,
The code runs like this
User selects record from Userform
Click Delete

Start Editing Function is called
Public Sub StartEditing()
  Dim peditor As IEditor
  Dim pID As New UID
  Dim pFeatureLayer As IFeatureLayer
  Dim pdataset As IDataset
  Dim pMap As IMap
  Dim pmxdoc As IMxDocument
  Dim LayerCount As Integer
  Set pmxdoc = Application.Document
  Set pMap = pmxdoc.FocusMap
  pID = "esriEditor.Editor"
  Set peditor = Application.FindExtensionByCLSID(pID)
  If peditor.EditState = esriStateEditing Then Exit Sub
  'Start editing the workspace of the first featurelayer you find
  Set pdataset = m_pFeatureClass
  peditor.StartEditing pdataset.Workspace
  peditor.StartOperation
      
End Sub


Feature is deleted

Stop Editing function is called

Public Sub stopSaveEdits()
    Dim peditor As IEditor
    Dim pID As New UID
    Dim pMap As IMap
    Dim pmxdoc As IMxDocument
    ' get the current map document and create and editor object
    Set pmxdoc = ThisDocument
    Set pMap = pmxdoc.FocusMap
    pID = "esriEditor.Editor"
    Set peditor = Application.FindExtensionByCLSID(pID)
    If peditor.EditState = esriStateEditing Then
        If peditor.HasEdits = True Then
            peditor.StopOperation "Saving..."
            peditor.StopEditing True
            MsgBox "EDITS HAVE BEEN MADE"
        Else
            peditor.StopOperation "Saving..."
            peditor.StopEditing False
            MsgBox "EDITS HAVE not BEEN MADE!!!"
        End If
    End If
End Sub


But the feature doesnt get deleted after the stop editing. What i have found is peditor.HasEdits  always returns false, even though I have made an edit in the edit session. Is this a bug or another way round this?

Cheers

halil

Outcomes