Select to view content in your preferred language

ArcPad 10 Script Error but No Script Error in ArcPad 8.0

2524
1
08-10-2012 08:24 AM
JayKirby
Occasional Contributor
Hi people, I have an annoying bug to figure out. I have a simple VB script to auto increment a numeric field to the next highest ID. I have two forms that onopen Call the script. Each form has the same script.

In ArPad 8.0 I have no script errors, and the forms load and numeric field auto increments as intended.

Using the same Check Out files (axf, apm etc) and I open it in ArcPad 10 I get a script error on only one of the forms:
[ATTACH=CONFIG]16832[/ATTACH]
Why would I get script errors in 10 and not 8?

Here is the script that I use for both forms:

Sub InitializeForm
'Do any form initialization in this sub
Dim objEFPageOneControls,objEditForm
Set objEditForm=ThisEvent.Object
Set objEFPageOneControls=objEditForm.Pages("page1").Controls
'Initilaization for form in any mode
'Disable the ID edit box
objEFPageOneControls("ID").Enabled=False
'Get the layer's recordset (to pass into the ReturnNextID function)
Dim objstlidRS
Set objstlidRS=Layer.Records
'Update the id and set the form to load on creation
If objEditForm.Mode=3 Then
objEFPageOneControls("ID").Value=ReturnNextID (objstlidRS, "ID")
End If
'Free Objects
Set objEFPageOneControls=Nothing
Set objEditForm=Nothing
Set objstlidRS=Nothing
'Application.Map.Layers("Completed_2012").Forms("EDITFORM").Pages("page1").Controls("ENTEREDBY").Value = Application.UserProperties("LoggedInEmployee")
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 neccessary
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

Thanks for the help if anyone can assist!

Jay Kirby
Tags (3)
0 Kudos
1 Reply
GerardFinan
New Contributor
Hi Jay,
Were you able to resolve this?

Regards

Gerry Finan
0 Kudos