Share via


MatchRecord method

Matches the current record to the map.

Applies to

Objects: Recordset

Syntax

object.MatchRecord([ShowDialogIfAmbiguous], [HWndParent])

Parameters

Part

Description

object

Required. An expression that returns a Recordset object.

ShowDialogIfAmbiguous

Optional Boolean. Opens the Match Records dialog box to enable matching individual records to the map if there is more than one good choice. Default value is False.

HWndParent

Optional Long. User's window handle.

Example

Note   This sample assumes that the code is running in a form or class module.

[Microsoft Visual Basic 6.0]
Sub MatchAnUnmatchedPushpin()

  Dim objApp As New MapPoint.Application
  Dim objPin As MapPoint.Pushpin
  Dim objRS As MapPoint.Recordset
  Dim objDS As MapPoint.DataSet

  objApp.Visible = True
  objApp.UserControl = True

  'Open a file that has unmatched records
  Set objDS = objApp.ActiveMap.DataSets.ShowImportWizard()

  'Get all records for the Pushpin data set
  Set objRS = objDS.QueryAllRecords

  'Find an unmatched Pushpin
  Do While Not objRS.EOF
    If objRS.IsMatched = False Then
      Set objPin = objRS.Pushpin
      Exit Do
    Else
      objRS.MoveNext
    End If
  Loop    'end if you get to end of the record set

  'If the current record position is not after the last record
    If Not objRS.EOF Then
      'Try to match it if it's not matched
      If Not objRS.IsMatched Then
        objRS.MatchRecord True
      Else
        MsgBox "No unmatched records."
      End If
    End If
End Sub

[C#]
void MatchAnUnmatchedPushpin()
{
  MapPoint.ApplicationClass objApp = new MapPoint.ApplicationClass();
  MapPoint.Pushpin objPin;

  objApp.Visible = true;
  objApp.UserControl = true;

  //Open a file that has unmatched records
  MapPoint.DataSet objDS = objApp.ActiveMap.DataSets.ShowImportWizard(0, "",
  MapPoint.GeoDelimiter.geoDelimiterDefault,0);

  //Get all records for the Pushpin data set
  MapPoint.Recordset objRS = objDS.QueryAllRecords();

  //Find an unmatched Pushpin
  while (!objRS.EOF)
  {
    if (objRS.IsMatched == false)
    {
      objPin = objRS.Pushpin;
      break;
    }
    else
    {
      objRS.MoveNext();
    }
  }//end if you get to end of the record set

  //If the current record position is not after the last record
    if(!objRS.EOF)
{
  //Try to match it if it's not matched
  if (!objRS.IsMatched)
  {
    objRS.MatchRecord(true, 0);
  }
  else
  {
    //Assume System.Windows.Forms.dll is referenced
    System.Windows.Forms.MessageBox.Show("No unmatched records.");
    }
  }
}