Hi all,
I'm stuck with a problem about how to retrieve fields values from another polygon feature when adding new point feature that falls inside one polyg.
I use an apx file that include a button to start editing, an apa file that define a log-in username to fill-in the shapefile and the apl and vbs file that manage the shapefile form.
The problem is that I use a polygon grid file (with an ID that I want to transfer in a field of my target shapefile) that has many features and the target-shapefile vb script works fine on pc but it becomes extremely slow on the handheld (Trimble Juno SB). So I decided to transfer the part of script concerning the polyg grid in the apx file, and store the ID in a user property in order to call it from the target-shapefile vb script. But I don't know why it doesn't work! No errors came out when running on arcpad and so i can't understand where is the problem.
Many thanks for your help
This is my code:
APX vbs file:
Option Explicit
Sub AddTree
Dim dblX, dblY, objToolButton, blnLyrExists
'Get a reference to the tool button object.
Set objToolButton = ThisEvent.Object
'Initialize blnLyrExists flag to False.
blnLyrExists = False
'If Trees layer exists,
'set the blnLyrExists flag to true.
Dim objLyr
For Each objLyr in Map.Layers
If StrComp (objLyr.Name, "Trees", 1) = 0 Then
blnLyrExists = True
Exit For
End If
Next
'If Trees layer does not exist,
'notify the user, return the tool button to its original state, and exit.
If Not blnLyrExists Then
MsgBox "The Trees layer is not present in the current map.", vbExclamation, "Layer not present"
objToolButton.Click
Exit Sub
End If
'If the Trees layer does exist,
'get the coordinates of the map where the user clicked.
dblX = Map.PointerX
dblY = Map.PointerY
'Get a reference to the Trees layer object.
Dim objLayer
Set objLayer = Map.Layers("Trees")
'If the layer can be made editable, make it editable.
If objLayer.CanEdit Then
objLayer.Editable = True
'Add a new tree (point feature) at the clicked location.
Call Map.AddFeatureXY(dblX,dblY)
'Return the tool button to its original state.
objToolButton.Click
End If
Dim cella,n_cella
cella = Map.Layers("Grigliato_v2").records.FindNearestXY (dblX,dblY)
Map.Layers("Grigliato_v2").records.bookmark = cella
n_cella = Map.Layers("Grigliato_v2").records.Fields("N__CELLA").Value
Application.UserProperties("cella") = n_cella
End Sub
The target-shapefile vbs:
Option Explicit
Public Sub MyFormOnLoad
Dim pThisPageControls
Set pThisPageControls = EDITFORM.Pages("Page1").Controls
pThisPageControls("edt_cella").Enabled = False 'disabilita l'edit nella textbox
pThisPageControls("edt_cella").Value = Application.UserProperties("cella")
set pThisPageControls = Nothing
end sub