Select to view content in your preferred language

How to programmatically clear highlight of selected feature in ArcPad 10?

2621
1
11-23-2011 07:11 AM
LesleyRoddam
Emerging Contributor
My code selects a feature on a particular layer if found at the point where teh user selects on the map. It then prompts a confirmation to delete the selected feature. If the user chooses "No", I want the selected feature to un-highlight. I'm trying to use the Layer>Highlight method which should unhighlight if given the value zero for the Bookmark argument.
When I run it, I get the error: "Object doesn't support this action."
How do I correct this line item to work properly?
I've included the whole sub, and the line in question is near the bottom "objLayer.Highlight(0)".

Sub DeleteGPSValve

  Dim dblX, dblY, blnFound, objLayer, sMessage, sOK
  'Get the coordinates of the map where the user clicked
  dblX = Map.PointerX
  dblY = Map.PointerY
  'Initialize blnLyrExists flag to False
  blnFound = False
  sMessage = "Delete the selected GPSValve?"

  For Each objLayer in Map.Layers
    If objLayer.name = "GPSvalves" Then
      if objLayer.CanEdit = False then
        msgbox "GPSValves are not available for editing."
        exit sub
      end if
      objLayer.Editable = True
     'If features are found set the blnFound flag to true
      blnFound= Map.SelectXY(dblx,dbly)
      If blnFound Then
        Exit For
      End If
    End If
  Next

  'If no feature was selected during above loop, exit
  If Not blnFound Then
    msgbox "no GPSValve found"
    Exit Sub
  End If

  Dim objRS
  Set objRS = objLayer.Records
  objRS.Bookmark = Application.Map.SelectionBookmark
  sOK=msgbox(sMessage, vbYesNo, "delete?")
  select case sOK
    case vbyes
      objRS.delete
      objRS.update
      Application.Map.Refresh(True)
    case vbno
      objLayer.Highlight(0)
      exit sub
  end select
  set objRS = Nothing

End Sub
Tags (3)
0 Kudos
1 Reply
EricMcPhee
Regular Contributor
I'm not sure why the way you are trying doesn't work....maybe there is more to a selection than just highlighting?

As an alternative, you could simply clear the selected features:

......
case vbno
  Application.ExecuteCommand ("clearselected")
exit sub
.......
0 Kudos