HOW TO
Note: This article pertains to ArcGIS versions 8.x and 9.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.
Instructions provide sample code showing how to set one field's data value equal to another field's value in a selected set of records.
Note: Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward
Modify ICalculator::Expression values to perform desired calculation, using the steps that follow.
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic "Creating custom commands with VBA and UI Controls".
Dim pMxDoc As IMxDocument Dim pFlayer As IFeatureLayer2 Dim pFClass As IFeatureClass Set pMxDoc = ThisDocument 'This assumes that the table is taken from the 'first layer listed in the Table of Contents Set pFlayer = pMxDoc.FocusMap.layer(0) Set pFClass = pFlayer.FeatureClass Dim pFeatureSel As IFeatureSelection Set pFeatureSel = pFlayer Dim pSelSet As ISelectionSet2 Set pSelSet = pFeatureSel.SelectionSet Dim pfCursor As IFeatureCursor pSelSet.Update Nothing, True, pfCursor Dim pCalculator As ICalculator Set pCalculator = New Calculator With pCalculator Set .Cursor = pfCursor .Expression = "[SOURCEFIELDNAME]" .Field = "TARGETFIELDNAME" End With pCalculator.Calculate
Article ID:000006321
Get help from ArcGIS experts
Download the Esri Support App