Select to view content in your preferred language

Why doesn't this work?

902
5
04-14-2010 10:00 AM
DouglasBurn
Emerging Contributor
I've created a button on an editform to delete the selected feature.  Here's the code that is called when the button is clicked:

Sub DeleteSighting

Dim objSightingsLayer
Dim objSelectedLayer

Set objSelectedLayer = Map.SelectionLayer

if objSelectedLayer is Nothing then
  msgBox("No feature is selected!")
  exit Sub
else
  Set objSightingsLayer = map.layers("Sightings")
  objSightingsLayer.Forms("EditForm").Close
  Application.ExecuteCommand("featuredelete")

end if

End Sub

When I click the button, the form closes, and the ArcPad dialog box asks me if I want to delete the selected feature.  However, when I say "yes," the feature is not deleted, and it becomes unselected.  If I select the feature and then use the "Delete Feature" command from the drawing tools menu, the feature is deleted as expected.  Any idea why the "delete feature" command doesn't work from my edit form?
Tags (3)
0 Kudos
5 Replies
BillCrawford
Emerging Contributor
I'm no coder but,

Should deleting come before closing in your code?
0 Kudos
DouglasBurn
Emerging Contributor
that the form should be closed first, before deleting the feature. But it was easy to move the ExecuteCommand statement in front of the form close statement.  Unfortunately, that doesn't work, either.
0 Kudos
BillCrawford
Emerging Contributor
Any way to view the code for ESRI's "Delete Feature" button in Arcpad for any tips?
0 Kudos
MattCooper
Regular Contributor
I think you might need to change your command name to "delete" instead of "featuredelete".  It's strange that it asks you to confirm the delete command though since "featuredelete" doesn't appear in the list of valid commands in the ArcPad developers help. 

Matt
0 Kudos
RolfBroch
Frequent Contributor
Since you have an editform open you must by definition have a selected object.

If you want to delete this object you can have a command button that sets a global boolean and then close the Editform and then in the onunload routine delete the object. The following subs contain the code (I have not tested it)

Sub cmdDeleteButtonClicked() 
  g_bDelete = True
  Editform.Close False
End If

Sub EditForm_OnUnLoad()
  If g_bDelete Then
    Application.ExecuteCommand("Delete")
  End If
  g_bDelete = False
End Sub

Rolf
0 Kudos