Hi,
I have an autonumber script that worked fine in ArcPad 7 with shapefiles. Now I am trying to get this script to work in ArcPad 10 wihtin an AXF. As you allready can imagine it gives an error, otherwise I would not create a new thread ;).
The script I am trying to use:
Option Explicit
Sub autonumber
'Do any form initialization in this sub
Dim objEFPageOneControls, objEditForm
Set objEditForm = ThisEvent.Object
Set objEFPageOneControls = objEditForm.Pages("form").Controls
'Initialization for form in any mode
'Disable the Tree ID edit box
objEFPageOneControls("txtElmId").Enabled = False
'Initialization for form when adding new records
If objEditForm.Mode = 3 Then
'Initialize DATE to current date objEFPageOneControls("dtpDate").Value = Now
'Get the City Trees layer's recordset (to pass into the ReturnNextID function)
Dim objCityTreesRS
Set objCityTreesRS = Layer.Records
'Update the Tree ID
objEFPageOneControls("txtElmID").Value = ReturnNextID (objCityTreesRS, "ElmID")
End If
'Free objects Set objEFPageOneControls = Nothing
Set objEditForm = Nothing
Set objCityTreesRS = Nothing
End Sub
Function ReturnNextID (objRS, strFieldName)
Dim intMax
'Get the first record
objRS.MoveFirst
'Initialize the max value to the first record
intMax = CInt(objRS.Fields(strFieldName).Value)
'Loop through the records, updating the max value if necessary
Dim intCurrVal
While Not objRS.EOF
intCurrVal = CInt(objRS.Fields(strFieldName).Value)
If (intCurrVal > intMax) Then
intMax = intCurrVal
End If
objRS.MoveNext
Wend
ReturnNextID = intMax + 1
End Function
It gives an script error 800A000D
I really like to get this to work under 10. For many applications an own auto numbering is needed.
Kind regards,
Lucien