Edit Attributes in User Form

Discussion created by davisphyllis on Jan 5, 2012
Latest reply on Jan 9, 2012 by Neil
I am trying to convert my old ArcGIS 9.3 (VBA) code to ArcGIS 10 using Visual Basic 2008 Express Edition. So far I have sucessfully created an pop-up window that displays the attributes of a selected feature in text boxes on the form.

However, I want to create a button that allows users to save any changes they make to the attributes in the user form. Below is the code I have thus far for the On_Click event to update the attributes.

The error I'm getting is on "IEditor.EditState <> esriStateEditing Then" IT says reference to non-shared member requires an object reference

Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
    Dim pMxDoc As IMxDocument
    pMxDoc = My.ArcMap.Document
    Dim pMap As IMap
    pMap = pMxDoc.FocusMap
    Dim pFLayer As IFeatureSelection

    Dim Count As Integer
    For Count = 0 To pMap.LayerCount - 1

        'Get the Transportation Improvement Line Layer from the Map
        If pMap.Layer(Count).Name = "TransportationImprovementProjects_Lines" Then
            pFLayer = pMap.Layer(Count)
            Dim pFCursor As IFeatureCursor = Nothing
            pFLayer.SelectionSet.Search(Nothing, False, pFCursor)
            Dim pF As IFeature
            pF = pFCursor.NextFeature
        End If

        'Get Dataset from FeatureLayer
        Dim pEditDataset As IDataset
        pEditDataset = pFLayer

        'If not editing, start editing dataset's Workspace
        If IEditor.EditState <> esriStateEditing Then
        End If

        'Initialize first (only) feature
        Dim pFeat As IFeature
        pFeat = pFLayer.NextFeature

        'Update attributes with user input
        pFeat.Value(pFeat.Fields.FindField("YEAR")) = txtPrjYear.Text
        pFeat.Value(pFeat.Fields.FindField("PROJECTYPE")) = txtPrjType.Text
        pFeat.Value(pFeat.Fields.FindField("LOCATION")) = txtLocation.Text
        pFeat.Value(pFeat.Fields.FindField("AGENCY")) = txtAgency.Text
        pFeat.Value(pFeat.Fields.FindField("DESCRIPTION")) = txtDescrip.Text
        pFeat.Value(pFeat.Fields.FindField("COST")) = txtCost.Text
        pFeat.Value(pFeat.Fields.FindField("DATEEDITED")) = txtDate.Text
        pFeat.Value(pFeat.Fields.FindField("USEREDITED")) = txtUser.Text

        'Store changes to feature

        'Stop editing and save edits

        'Refresh map

        'Close form
    Next Count
End Sub