Select to view content in your preferred language

ArcPad vbscript- How to zoom to selected records

3427
0
05-01-2015 09:19 AM
JuneAcosta
Occasional Contributor III

Hi all,

I need help with my custom tool button.....

There's sample code to zoom to a selected record, but I'm having trouble finding sample code that will zoom to a selection set(more than one feature) of point features/records.

Here the work flow...

1) A user would filter the trees based on inspection type, then only those trees would show on the map.

2) then I created another button to reset the field TreeActivity to NULL.

3) When a tree is inspected the user will calc the TreeActivity field to "Inspected" and the symbol of the tree would change, so the user would know what trees are left to be inspected.

The button in step 2 is where I need the to be able to zoom to the extent of all selected records. Here's my sub for step 2. Application.ExecuteCommand("zoomfullextent") is zooming the extent of the layer and not the selected features,

Sub ResetActivity


  Dim treeDataSource, cntQry, testSQL
  Set treeDataSource = Map.Layers("Tree").Datasource
  Set cntQry = treeDataSource.Execute("SELECT * FROM [TREE] WHERE " & sqlFilter & " AND TREEACTIVITY = 'VACANT'")
  if cntQry.recordCount > 0 then
  MsgBox cntQry.recordcount & " records will be reset NULL"
  'treeDataSource.Execute("UPDATE [TREE] SET TREEACTIVITY = 2 WHERE " & sqlFilter & "")
  testSQL = "UPDATE [TREE] SET TREEACTIVITY = 2 WHERE " & sqlFilter
  MsgBox testSQL
  Application.ExecuteCommand("zoomfullextent")
  else
  MsgBox "No records Selected"
  end if


  treeDataSource.Close()

  'Clear objects
  Set treeDataSource = Nothing
  Set cntQry = Nothing


End Sub
0 Kudos
0 Replies