I'm trying to create a Unique ID that pops up on a custom form I'm making in ArcPAD. This is needed so field workers can include this number on some supplemental paper tables that they carry around.
I've pasted together the following code which mostly works; however, if someone uses the repeat attributes toggle then the "unique" ID is also repeated.
Is there any way to test to see if the repeat attributes toggle is on or off?
I can't find it anywhere in the Object Model.
Here's my code. This runs on the ONLOAD event for the form (sorry for the lack of documentation). This basically just loops through the features and finds the highest number in the ID field and adds 1. If the ID box on the form is already populated this is not executed.
Option Explicit
Dim varUniqueID
Sub UniqueID2
Dim objRS, HighValue, CurrentValue, objEFPageOneControls, objEditForm
Set objRS = Application.map.layers("OFF_ROAD").records
Set objEditForm = application.map.layers("OFF_ROAD").forms("EDITFORM")
Set objEFPageOneControls = objEditForm.Pages("Page1").Controls
If (objEFPageOneControls("IDBOX").Value = "") Then
If (objRS.RecordCount > 0) Then
objRS.Movefirst
HighValue = objRS.Fields("ID").Value
objRS.MoveNext
While Not objRS.EOF
CurrentValue = objRS.Fields("ID").Value
if HighValue < CurrentValue Then
HighValue = CurrentValue
End If
objRS.MoveNext
Wend
HighValue = HighValue + 1
End If
objEFPageOneControls("IDBOX").Value = HighValue
End If
End Sub
No comments:
Post a Comment