Hey all thanks for your time!
I have this script created for auto incrementing my TREE_ID field in my table (TREE_ID = control). Long story short the script runs
from what i can tell and may even increment the first one but then stops. No errors either. The first point i put down starts with 2 but then it does not increment from there. Do i need to do anything with the strFieldName or intMax to make it work correctly?
Note: fairly new to working with script.
IF YOU SEE ANYTHING OUT OF PLACE LET ME KNOW! 😛
'InitializeForm
Sub InitializeForm
Dim objEFControls, objEditForm
Set objEditForm = ThisEvent.Object
Set objEFControls = objEditForm.Pages("Page1").Controls
If objEditForm.Mode = 3 Then
Dim objTreeInitRS
Set objTreeInitRS = Layer.Records
objEFControls("TREE_ID").Value = ReturnNextID (objTreeInitRS, "TreeInit")
End If
Set objTreeInitRS = nothing
Set objEFControls = nothing
Set objEditForm = nothing
End Sub
'ReturnNextID
Function ReturnNextID (objRS, TREE_ID)
Dim intMax
objRS.MoveFirst
intMax = 1
Dim intCurrVal
While Not objRS.EOF
intCurrVal = Clng(objRS.Fields(TREE_ID).Value)
If (intCurrVal > intMax) And (intCurrVal < 5000) Then
intMax = intCurrVal
End If
objRS.MoveNext
Wend
ReturnNextID = intMax + 1
Set intMax = nothing
Set intCurrVal = nothing
End Function
Any help would be appreciated.
'supplement info Layer=TreeInit, Form= EditForm, Page= Page1, Control/field name = TREE_ID