HOW TO
This article shows how to create and populate a new row in an INFO table.
Note:
Code in ThisDocument code module will only run in the current map document. To store the code in all map documents, open the code in the Normal.mxt ThisDocument code module.
Code:
Sub AddRow()
Dim pWorkspace As IWorkspaceFactory
Set pWorkspace = New ArcInfoWorkspaceFactory
Dim pFeatureWorkspace As IFeatureWorkspace
Set pFeatureWorkspace = pWorkspace.OpenFromFile("c:\temp", 0)
Dim pWorkspaceEdit As IWorkspaceEdit
Set pWorkspaceEdit = pFeatureWorkspace
Dim pTable As ITable
Set pTable = pFeatureWorkspace.OpenTable("owner.dat")
'Start an edit session
pWorkspaceEdit.StartEditing True
pWorkspaceEdit.StartEditOperation
'Add the row
Dim pRow As IRow
Set pRow = pTable.CreateRow
pRow.Value(1) = "Gilbert"
pRow.Store
'Stop the edit session
pWorkspaceEdit.StopEditOperation
pWorkspaceEdit.StopEditing True
End Sub
Article ID:000004963
Get help from ArcGIS experts
Download the Esri Support App