Rematching a Geocoded Feature Class Interactively

Created:01/09/2001
Description:

This VBA code demonstrates how to rematch a geocoded feature class interactively.

To rematch a geocoded feature class, you must get the Locator that was attached to the feature class when it was created. You can then use the Locator's AddressLocatorUI object to rematch the geocoded feature class automatically.

When rematching a geocoded feature class interactively, you can use a QueryFilter to specify which features to rematch.


How to use:
  1. Paste this code into VBA in ArcCatalog.
  2. In the ArcCatalog tree, select a geocoded feature class or shapefile.
  3. Run the RematchInteractively macro.
  4. Use the Interactive Rematch dialog to interactively rematch the geocoded feature class.
Option Explicit

Private Const MESSAGEBOX_TITLE = "Rematch Interactively Geocoding Developer Tip"

Public Sub RematchInteractively()

  Dim pAddressUI As esriCore.IAddressUI    'address UI for the Locator
  Dim pAttachedLocator As esriCore.IAttachedLocator   'AttachedLocator for the selected Dataset
  Dim pGxApplication As esriCore.IGxApplication   'ArcCatalog application
  Dim pGxDataset As esriCore.IGxDataset   'selected Dataset
  Dim pGxObject As esriCore.IGxObject   'selected object
  Dim pLocator As esriCore.ILocator   'Locator used to geocode the selected Dataset
  Dim pLocatorManager As esriCore.ILocatorManager   'LocatorManager object
  
  '** get a reference to the parent application
  If Not (TypeOf ThisDocument.Parent Is esriCore.IGxApplication) Then
    MsgBox "This macro can only be used in ArcCatalog.", vbCritical, MESSAGEBOX_TITLE
    Exit Sub
  End If
  Set pGxApplication = ThisDocument.Parent
  
  '** get a reference to the seleted geocoded feature class
  Set pGxObject = pGxApplication.SelectedObject
  If Not TypeOf pGxObject Is esriCore.IGxDataset Then
    MsgBox "The selected item is not a geocoded feature class.", vbCritical, _
      MESSAGEBOX_TITLE
    Exit Sub
  End If
  Set pGxDataset = pGxObject
  '** determine if the selected dataset is a geocoded feature class
  Set pLocatorManager = New esriCore.LocatorManager
  If Not pLocatorManager.HasLocatorAttached(pGxDataset.DatasetName) Then
    MsgBox "The selected item is not a geocoded feature class.", vbCritical, _
      MESSAGEBOX_TITLE
    Exit Sub
  End If
   
  '** get the attached locator from the dataset
  Set pAttachedLocator = pLocatorManager.GetLocatorFromDataset(pGxDataset.Dataset)
  Set pLocator = pAttachedLocator.Locator
  
  '** rematch the feature class interactively
  Set pAddressUI = pLocator.UserInterface
  With pAttachedLocator
    pAddressUI.InteractiveReview ThisDocument.Parent.hWnd, .InputTable, Nothing, _
      .InputFieldNamesList, .InputJoinFieldName, .OutputTable, .OutputFieldNamesList, _
      .OutputJoinFieldName, pLocator
  End With
  
End Sub