Hi All,I am working on a project in ArcPad 8 SP3.I have a Shapefile with to fields- UserNumber (Long Integer)
- UserText3 (Text Field)
Below is my Code that i have created to autogenerate a Unique ID and my Text_box that it relates to will store that value that is returned to UserNumber. How would I go about adding that value directly to the Attribute table for UserText3?
Sub InitialiseGPSID
'Do any form initialization in this sub
Dim objEFPageOneControls, objEditForm
Set objEditForm = ThisEvent.Object
Set objEFPageOneControls = objEditForm.Pages("PAGE1").Controls
'Initialization for form in any mode
'Disable the GPS ID edit box
objEFPageOneControls("txt_GPSID").Enabled = False
'Initialization for form when adding new records
If objEditForm.Mode = 3 Then ' Mode 3 is used when creating a new feature.
'Get the Fence Points layer's recordset (to pass into the ReturnNextID function)
Dim objUniqueID
Set objUniqueID = Layer.Records
if ReturnNextID (objUniqueID, "USERNUMBER") = 1 then
'Update the Tree ID
objEFPageOneControls("txt_GPSID").Value = ReturnNextID (objUniqueID, "USERNUMBER") + 10000
else
objEFPageOneControls("txt_GPSID").Value = ReturnNextID (objUniqueID, "USERNUMBER")
end if
End If
'Free objects
Set objEFPageOneControls = Nothing
Set objEditForm = Nothing
Set objUniqueID = Nothing
End Sub
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'Also write the function ReturnNextID that is called by InitializeForm.
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
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\