Estoy trabajando en una herramienta de automatización de ArcPad para las cuestiones de inventario en nuestra máquina móvil GIS (Trimble GeoXH - Geoexplorer 2008 series - Windows mobile 6.1 y Arcdap 10.0.3). He desarrollado la herramienta en VBscript. Breve descripción de lo que debe hacer la herramienta: Tenemos un shapefile de puntos en Arcpad. Cada vez que añadimos un punto manualmente, se cuenta automáticamente el nuevo ID haciendo clic en un botón de la barra de herramientas. El nuevo ID es el último ID + 1. Ya he conseguido recorrer los atributos, encontrar el último ID y calcular un nuevo ID. Sin embargo, no puedo añadir el nuevo ID calculado para el punto añadido en la tabla de atributos. Es como si no pudiera abrir el recordset en modo de edición. A continuación se encuentra mi código fuente.
¿Sabes qué estoy haciendo mal?
Gracias por la ayuda.
Código fuente
Subprueba
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