Solved! Go to Solution.
The error is occurring at tableInsertCursor = outputSignDetailTable.InsertRow(True).
Protected Overrides Sub OnClick() Implements ESRI.ArcGIS.SystemUI.ICommand.OnClick Dim pMxDoc As IMxDocument = TryCast(My.ArcMap.Application.Document, IMxDocument) Dim enumFeatureSetup As IEnumFeatureSetup Dim shape As String If pMxDoc Is Nothing Then Return End If Dim pMap As IMap = pMxDoc.FocusMap Dim pEF As IEnumFeature = pMap.FeatureSelection enumFeatureSetup = pEF enumFeatureSetup.AllFields = True Dim pFeat As IFeature = pEF.Next If pFeat Is Nothing Then Exit Sub End If Dim fields As IFields fields = pFeat.Fields Dim fieldCount As Integer = 0 Dim field, ffield As IField Dim IDvalue, Lvalue, Mvalue, Rvalue As String Dim Ovalue As Integer Dim StrArray() As String = {"speedsigns", "intersections", "unpaved", "rumble", "paved", "medians", "lanes", "lighting", "location"} Do While pFeat IsNot Nothing If Array.IndexOf(StrArray, pFeat.Class.AliasName) = -1 Then Do Until fieldCount = fields.FieldCount field = pFeat.Fields.Field(fieldCount) If field.Name = "RandomID" Then IDvalue = pFeat.Value(fieldCount) ElseIf field.Name = "Lighting" Then Lvalue = pFeat.Value(fieldCount) ElseIf field.Name = "RumbleStri" Then Rvalue = pFeat.Value(fieldCount) ElseIf field.Name = "Median" Then Mvalue = pFeat.Value(fieldCount) ElseIf field.Name = "OBJECTID" Then Ovalue = pFeat.Value(fieldCount) End If fieldCount += 1 Loop Exit Do End If pFeat = pEF.Next Loop pEF = pMap.FeatureSelection enumFeatureSetup = pEF enumFeatureSetup.AllFields = True pFeat = pEF.Next Dim commandItem As ICommandItem Dim commandBars As ICommandBars commandBars = My.ArcMap.Application.Document.CommandBars commandItem = commandBars.Find(My.ThisAddIn.IDs.ArcGISAddin1, True, False) Dim workspacePath As String = ArcMapAddin1.ArcGISAddin3.val Dim workspaceFactory As IWorkspaceFactory Dim workspace As IWorkspace Try workspaceFactory = DirectCast(Activator.CreateInstance(Type.GetTypeFromProgID("esriDataSourcesGDB.AccessWorkspaceFactory")), IWorkspaceFactory) workspace = workspaceFactory.OpenFromFile(workspacePath, My.ArcMap.Application.hWnd) Catch ex As Exception MsgBox("Database Not Found") Exit Sub End Try Dim rset As String = "hold" Dim fieldcount2 As Integer pFeat = pEF.Next shape = ArcMapAddin1.ArcGISAddin1.val Dim outputSignDetailTable As ITable Dim tableBuffer As IRowBuffer Dim row As IRow Dim feature As IRowBuffer Dim pEF2 As IEnumFeature = pMap.FeatureSelection Dim enumFeatureSetup2 As IEnumFeatureSetup enumFeatureSetup2 = pEF2 enumFeatureSetup2.AllFields = True Dim pFeat2 As IFeature = pEF2.Next Dim speedsigns As Integer = 0 Dim intersections As Integer = 0 Dim unpaved As Integer = 0 Dim rumble As Integer = 0 Dim paved As Integer = 0 Dim medians As Integer = 0 Dim lanes As Integer = 0 Dim lighting As Integer = 0 Dim location As Integer = 0 Do While pFeat2 IsNot Nothing If pFeat2.Class.AliasName = "speedsigns" Then speedsigns += 1 ElseIf pFeat2.Class.AliasName = "intersections" Then intersections += 1 ElseIf pFeat2.Class.AliasName = "unpaved" Then unpaved += 1 ElseIf pFeat2.Class.AliasName = "rumble" Then rumble += 1 ElseIf pFeat2.Class.AliasName = "paved" Then paved += 1 ElseIf pFeat2.Class.AliasName = "medians" Then medians += 1 ElseIf pFeat2.Class.AliasName = "lanes" Then lanes += 1 ElseIf pFeat2.Class.AliasName = "lighting" Then lighting += 1 ElseIf pFeat2.Class.AliasName = "location" Then location += 1 End If pFeat2 = pEF2.Next() Loop Dim iii As Integer pEF = pMap.FeatureSelection enumFeatureSetup = pEF enumFeatureSetup.AllFields = True pFeat = pEF.Next pFeat = pEF.Next Dim tableInsertCursor As ICursor Dim newOID As Object Do While pFeat IsNot Nothing If shape = pFeat.Class.AliasName Then outputSignDetailTable = DirectCast(workspace, IFeatureWorkspace).OpenTable(shape) tableBuffer = outputSignDetailTable.CreateRowBuffer() row = CType(tableBuffer, IRow) feature = tableBuffer tableInsertCursor = outputSignDetailTable.InsertRow(True) feature.Value(0) = IDvalue feature.Value(1) = Ovalue fieldcount2 = 1 Do Until fieldcount2 = pFeat.Fields.FieldCount iii = 0 Do While iii < outputSignDetailTable.Fields.FieldCount ffield = outputSignDetailTable.Fields.Field(iii) If ffield.AliasName = pFeat.Fields.Field(fieldcount2).AliasName Then feature.Value(iii) = pFeat.Value(fieldcount2) Exit Do End If iii += 1 Loop fieldcount2 += 1 Loop If shape = "rumble" Then fieldcount2 += 1 If rset = "hold" Then If MsgBox("Are these rumble strips a set?", vbYesNo) = vbYes Then rset = "yes" iii = 0 Do While iii < outputSignDetailTable.Fields.FieldCount ffield = outputSignDetailTable.Fields.Field(iii) If ffield.AliasName = "Set" Then feature.Value(iii) = "SET" Exit Do End If iii += 1 Loop Else rset = "no" End If ElseIf rset = "yes" Then iii = 0 Do While iii < outputSignDetailTable.Fields.FieldCount ffield = outputSignDetailTable.Fields.Field(iii) If ffield.AliasName = "Set" Then feature.Value(iii) = "SET" Exit Do End If iii += 1 Loop End If End If If shape <> "location" Then commandItem = commandBars.Find(My.ThisAddIn.IDs.Process2, True, False) If commandItem.Caption = "Ambiguity On" Then iii = 0 Do While iii < outputSignDetailTable.Fields.FieldCount ffield = outputSignDetailTable.Fields.Field(iii) If ffield.AliasName = "Ambiguity" Then feature.Value(iii) = "AMBIG" Exit Do End If iii += 1 Loop End If End If commandItem = commandBars.Find(My.ThisAddIn.IDs.Process3, True, False) If commandItem.Caption = "Double Check On" Then iii = 0 Do While iii < outputSignDetailTable.Fields.FieldCount ffield = outputSignDetailTable.Fields.Field(iii) If ffield.AliasName = "Check" Then feature.Value(iii) = "CHECK" Exit Do End If iii += 1 Loop tableInsertCursor.InsertRow(feature) Else tableInsertCursor.InsertRow(feature) End If End If pFeat = pEF.Next() Loop End Sub
I am using 10.1 sp1.Protected Overrides Sub OnClick() Implements ESRI.ArcGIS.SystemUI.ICommand.OnClick Dim pMxDoc As IMxDocument = TryCast(My.ArcMap.Application.Document, IMxDocument) Dim enumFeatureSetup As IEnumFeatureSetup Dim shape As String If pMxDoc Is Nothing Then Return End If Dim pMap As IMap = pMxDoc.FocusMap Dim pEF As IEnumFeature = pMap.FeatureSelection enumFeatureSetup = pEF enumFeatureSetup.AllFields = True Dim pFeat As IFeature = pEF.Next If pFeat Is Nothing Then Exit Sub End If Dim fields As IFields fields = pFeat.Fields Dim fieldCount As Integer = 0 Dim field, ffield As IField Dim IDvalue, Lvalue, Mvalue, Rvalue As String Dim Ovalue As Integer Dim StrArray() As String = {"speedsigns", "intersections", "unpaved", "rumble", "paved", "medians", "lanes", "lighting", "location"} Do While pFeat IsNot Nothing If Array.IndexOf(StrArray, pFeat.Class.AliasName) = -1 Then Do Until fieldCount = fields.FieldCount field = pFeat.Fields.Field(fieldCount) If field.Name = "RandomID" Then IDvalue = pFeat.Value(fieldCount) ElseIf field.Name = "Lighting" Then Lvalue = pFeat.Value(fieldCount) ElseIf field.Name = "RumbleStri" Then Rvalue = pFeat.Value(fieldCount) ElseIf field.Name = "Median" Then Mvalue = pFeat.Value(fieldCount) ElseIf field.Name = "OBJECTID" Then Ovalue = pFeat.Value(fieldCount) End If fieldCount += 1 Loop Exit Do End If pFeat = pEF.Next Loop pEF = pMap.FeatureSelection enumFeatureSetup = pEF enumFeatureSetup.AllFields = True pFeat = pEF.Next Dim commandItem As ICommandItem Dim commandBars As ICommandBars commandBars = My.ArcMap.Application.Document.CommandBars commandItem = commandBars.Find(My.ThisAddIn.IDs.ArcGISAddin1, True, False) Dim workspacePath As String = ArcMapAddin1.ArcGISAddin3.val Dim workspaceFactory As IWorkspaceFactory Dim workspace As IWorkspace Try workspaceFactory = DirectCast(Activator.CreateInstance(Type.GetTypeFromProgID("esriDataSourcesGDB.AccessWorkspaceFactory")), IWorkspaceFactory) workspace = workspaceFactory.OpenFromFile(workspacePath, My.ArcMap.Application.hWnd) Catch ex As Exception MsgBox("Database Not Found") Exit Sub End Try Dim rset As String = "hold" Dim fieldcount2 As Integer pFeat = pEF.Next shape = ArcMapAddin1.ArcGISAddin1.val Dim outputSignDetailTable As ITable Dim tableBuffer As IRowBuffer Dim row As IRow Dim feature As IRowBuffer Dim pEF2 As IEnumFeature = pMap.FeatureSelection Dim enumFeatureSetup2 As IEnumFeatureSetup enumFeatureSetup2 = pEF2 enumFeatureSetup2.AllFields = True Dim pFeat2 As IFeature = pEF2.Next Dim speedsigns As Integer = 0 Dim intersections As Integer = 0 Dim unpaved As Integer = 0 Dim rumble As Integer = 0 Dim paved As Integer = 0 Dim medians As Integer = 0 Dim lanes As Integer = 0 Dim lighting As Integer = 0 Dim location As Integer = 0 Do While pFeat2 IsNot Nothing If pFeat2.Class.AliasName = "speedsigns" Then speedsigns += 1 ElseIf pFeat2.Class.AliasName = "intersections" Then intersections += 1 ElseIf pFeat2.Class.AliasName = "unpaved" Then unpaved += 1 ElseIf pFeat2.Class.AliasName = "rumble" Then rumble += 1 ElseIf pFeat2.Class.AliasName = "paved" Then paved += 1 ElseIf pFeat2.Class.AliasName = "medians" Then medians += 1 ElseIf pFeat2.Class.AliasName = "lanes" Then lanes += 1 ElseIf pFeat2.Class.AliasName = "lighting" Then lighting += 1 ElseIf pFeat2.Class.AliasName = "location" Then location += 1 End If pFeat2 = pEF2.Next() Loop Dim iii As Integer pEF = pMap.FeatureSelection enumFeatureSetup = pEF enumFeatureSetup.AllFields = True pFeat = pEF.Next pFeat = pEF.Next Dim tableInsertCursor As ICursor Dim newOID As Object Do While pFeat IsNot Nothing If shape = pFeat.Class.AliasName Then outputSignDetailTable = DirectCast(workspace, IFeatureWorkspace).OpenTable(shape) tableBuffer = outputSignDetailTable.CreateRowBuffer() row = CType(tableBuffer, IRow) feature = tableBuffer tableInsertCursor = outputSignDetailTable.InsertRow(True) feature.Value(0) = IDvalue feature.Value(1) = Ovalue fieldcount2 = 1 Do Until fieldcount2 = pFeat.Fields.FieldCount iii = 0 Do While iii < outputSignDetailTable.Fields.FieldCount ffield = outputSignDetailTable.Fields.Field(iii) If ffield.AliasName = pFeat.Fields.Field(fieldcount2).AliasName Then feature.Value(iii) = pFeat.Value(fieldcount2) Exit Do End If iii += 1 Loop fieldcount2 += 1 Loop If shape = "rumble" Then fieldcount2 += 1 If rset = "hold" Then If MsgBox("Are these rumble strips a set?", vbYesNo) = vbYes Then rset = "yes" iii = 0 Do While iii < outputSignDetailTable.Fields.FieldCount ffield = outputSignDetailTable.Fields.Field(iii) If ffield.AliasName = "Set" Then feature.Value(iii) = "SET" Exit Do End If iii += 1 Loop Else rset = "no" End If ElseIf rset = "yes" Then iii = 0 Do While iii < outputSignDetailTable.Fields.FieldCount ffield = outputSignDetailTable.Fields.Field(iii) If ffield.AliasName = "Set" Then feature.Value(iii) = "SET" Exit Do End If iii += 1 Loop End If End If If shape <> "location" Then commandItem = commandBars.Find(My.ThisAddIn.IDs.Process2, True, False) If commandItem.Caption = "Ambiguity On" Then iii = 0 Do While iii < outputSignDetailTable.Fields.FieldCount ffield = outputSignDetailTable.Fields.Field(iii) If ffield.AliasName = "Ambiguity" Then feature.Value(iii) = "AMBIG" Exit Do End If iii += 1 Loop End If End If commandItem = commandBars.Find(My.ThisAddIn.IDs.Process3, True, False) If commandItem.Caption = "Double Check On" Then iii = 0 Do While iii < outputSignDetailTable.Fields.FieldCount ffield = outputSignDetailTable.Fields.Field(iii) If ffield.AliasName = "Check" Then feature.Value(iii) = "CHECK" Exit Do End If iii += 1 Loop tableInsertCursor.InsertRow(feature) Else tableInsertCursor.InsertRow(feature) End If End If pFeat = pEF.Next() Loop End Sub