Hello,
I am working on an automating tool for ArcPad for inventory issues on our mobile GIS machine (Trimble GeoXH - Geoexplorer 2008 series - Windows mobile 6.1 and Arcdap 10.0.3) in VBscript. Short description of what the tool is supposed to do:
We have a point shapefile in Arcpad. Everytime when we manually add a point, it automaticaly counts the new ID by clicking on a button in the toolbar. The new ID is the last ID + 1. I succeeded already in looping through the attributes, finding the last ID and calculating a new ID. 😮 However, I can't add the new calculated ID for the added point in the attribute table :mad: ... It's like I can't open the recordset in edit mode.
Below you find my source code.
Anybody kows what I'm doing wrong? Thanks for helping me!
Kris
My Sourcecode:
Sub Test
Dim objDBF, strLaatstePaalID, NewPaalNR, NewPaalID, Nummer, PaalCode
Numbre = 0
Set objLyr = Map.Layers("Palen")
Set objDBF = objLyr.Records
'Look for record with the highest ID
'ID is text format like 'P_00450'
objDBF.MoveFirst
Do Until objDBF.EOF
PaalCode = objDBF.Fields("PAAL_ID").Value
If PaalCode <> "" Then 'the new added point (which is the last) has no value in the ID
If Int(Right(PaalCode,(Len(PaalCode)-2)))>Numbre Then
'Make an integer of the text code
Numbre = Int(Right(PaalCode,(Len(PaalCode)-2)))
End If
End If
objDBF.MoveNext
Loop
NewPaalNR = Numbre + 1
'Maak een nieuw text ID with the new numbre
If NewPaalNR < 10 Then
NewPaalID = "P_0000" & CStr(NewPaalNR)
ElseIf NewPaalNR < 100 Then
NewPaalID = "P_000" & CStr(NewPaalNR)
ElseIf NewPaalNR < 1000 Then
NewPaalID = "P_00" & CStr(NewPaalNR)
ElseIf NewPaalNR < 10000 Then
NewPaalID = "P_0" & CStr(NewPaalNR)
Else
NewPaalID = "P_" & CStr(NewPaalNR)
End If
MsgBox ("New Id: " & NewPaalID)
'go to the new added point
objDBF.MoveLast
if objDBF.Fields("PAAL_ID").Value ="" Then
'add the new value
objDBF.Fields("PAAL_ID").Value = NewPaalID
objDBF.Update
MsgBox("Paal_ID " & NewPaalID & " added in Palen.shp")
Else
MsgBox("No empty feature added")
End If
Set objDBF = Nothing
End Sub