IsPrimaryKey property

Returns whether the Field object is the primary key field. Valid only for linked sets. Always False for fields in DataSet objects with a HowCreated property of geoDataSetDemographic. Read-only Boolean.

Applies to

Objects:  Field




Part Description
object Required. An expression that returns a Field object.


    Sub FindPrimaryKeyField()
  Dim objApp As New MapPoint.Application
  Dim objDataSet As MapPoint.DataSet
  Dim objFld As MapPoint.Field
  objApp.Visible = True
  objApp.UserControl = True

  'Get a data set to a linked file
  Set objDataSet = objApp.ActiveMap.DataSets.ShowLinkWizard()

  'Check to make sure that it is linked
  If Not objDataSet.IsLinked Then
    MsgBox "Data set is not linked."
    Exit Sub
  End If

  'Find the primary field
  For Each objFld In objDataSet.Fields
    If objFld.IsPrimaryKey Then Exit For

  MsgBox "The primary key field is: " & objFld.Name