At my work we use ArcPad to collect inspection point data. One of the fields is SITEID that is manually entered by a staff member (its a combination of their initials and a number (eg ST01). I would like to add an event handler (I'm using OnChange in my code) to my APL file that checks if the SITEID already exists. Im finding it very difficult to debug in ArcStudio so any help would be greatly appreciated!

Below is my APL file

<?xml version="1.0" encoding="UTF-8"?>
<LAYER name="SoilSurvey_InspectionSitesSimple_UTM10N" transparency="1">
        <EDITFORM name="EDITFORM" caption="Soil Inspection Sites" width="160" height="150" color="Blue" picturepagevisible="true" attributespagevisible="true" symbologypagevisible="true" geographypagevisible="true" required="false">
            <PAGE name="SiteDetails" caption="Site Details">
                <LABEL name="slblSiteID" x="3" y="3" width="35" height="10" caption="Site ID" tooltip="" group="true" border="false"/>
                <LABEL name="slblDate" x="3" y="18" width="35" height="10" caption="Date" tooltip="" group="true" border="false"/>
                <EDIT name="txtSiteID" x="45" y="1" width="75" height="12" defaultvalue="" **onchange="Call CheckSITEID"** tooltip="" tabstop="true" border="true" required="true" field="SITEID" uppercase="true" multiline="true"/>
                <DATETIME name="dtDate" x="45" y="17" width="75" height="12" defaultvalue="Now ()" tooltip="" tabstop="true" border="true" field="DATE_"/>
                <LABEL name="slblComments" x="3" y="35" width="35" height="10" caption="Comments" tooltip="" group="true" border="false"/>
                <EDIT name="txtComments" x="3" y="48" width="100" height="50" defaultvalue="" tooltip="" tabstop="true" border="true" field="Comments" uppercase="true" multiline="true"/>
        <SIMPLELABELRENDERER visible="false" field="" rotationfield="" expression="" language="">
            <TEXTSYMBOL fontcolor="Black" font="Arial" fontsize="8" vertalignment="bottom" rtl="false" fontstyle="regular"/>
            <SIMPLEMARKERSYMBOL color="76,230,0" width="3" outlinewidth="1"/>
    <QUERY where=""/>
            <FIELD name="X"/>
            <FIELD name="Y"/>
            <FIELD name="SITEID" value="3"/>
            <FIELD name="Z"/>
            <FIELD name="DATE_"/>
            <FIELD name="ID"/>
            <FIELD name="Comments" value=""/>

<SCRIPT language="VBScript">
    Sub CheckSITEID
    Dim objEditForm, InputSite, ExistingRec
    Set  InputSite = ThisEvent.Object.Value 
    Dim objRS
    Set objRS = Map.Selectionlayer.Records
    If (objRS.RecordCount > 0) Then
        While Not objRS.EOF
            Set ExistingRec = objRS.Fields("SITEID").Value
            If InputSite = ExistingRec Then
            ThisEvent.Result = False
            ThisEvent.MessageText  = "SITEID ALREADY EXISTS"
            End If
    End If
    End Sub
</SCRIPT language="VBScript">
  • Are you receiving any errors? Have you tried checking both the InputSite and ExistingRec values within a messagebox to see what they are?
    – artwork21
    Commented Jun 8, 2013 at 2:35
  • I'm not getting any errors but I still can add multiple points with the same siteid so its not working. How do I add a message box? is it ThisEven.MessageText = "InputSite:"& InputSite ?
    – user17963
    Commented Jun 9, 2013 at 17:53

1 Answer 1


Hopefully this will help? I needed something similiar.. I put this on the onValidate event

Dim pole, existing, record
Set pole = Map.Layers("Pole").Records
record = ThisEvent.Object.Value

Do Until pole.EOF
     existing = pole.Fields("IMAGE").Value
     If existing = record Then
        ThisEvent.Result = False
        ThisEvent.MessageText = "This image already exists"
     ElseIf record = "" Then
        ThisEvent.Result = True
     End If

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.