Select to view content in your preferred language

ArcPad APL - enforcing unique values

1215
1
06-07-2013 05:51 PM
KarenThomas2
New Contributor
t 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"?>
    <ArcPad>
<LAYER name="SoilSurvey_InspectionSitesSimple_UTM10N" transparency="1">
    <FORMS>
        <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"/>
            </PAGE>
        </EDITFORM>
    </FORMS>
    <SYMBOLOGY>
        <SIMPLELABELRENDERER visible="false" field="" rotationfield="" expression="" language="">
            <TEXTSYMBOL fontcolor="Black" font="Arial" fontsize="8" vertalignment="bottom" rtl="false" fontstyle="regular"/>
        </SIMPLELABELRENDERER>
        <SIMPLERENDERER>
            <SIMPLEMARKERSYMBOL color="76,230,0" width="3" outlinewidth="1"/>
        </SIMPLERENDERER>
    </SYMBOLOGY>
    <METADATA/>
    <QUERY where=""/>
    <FIELDHISTORY>
        <FIELDS>
            <FIELD name="X"/>
            <FIELD name="Y"/>
            <FIELD name="SITEID" value="3"/>
            <FIELD name="Z"/>
            <FIELD name="DATE_"/>
            <FIELD name="ID"/>
            <FIELD name="Comments" value=""/>
        </FIELDS>
    </FIELDHISTORY>
    </LAYER>

<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
        objRS.Movefirst
        While Not objRS.EOF
            Set ExistingRec = objRS.Fields("SITEID").Value
            If InputSite = ExistingRec Then
            ThisEvent.Result = False
            ThisEvent.MessageText  = "SITEID ALREADY EXISTS"
            End If
            objRS.MoveNext
         Wend
    End If
    End Sub
</SCRIPT language="VBScript">
</ArcPad>
Tags (3)
0 Kudos
1 Reply
DeniseKing
Esri Regular Contributor
Look at the Incrementing ID's sample on ArcGIS Resource Center as described in ArcPad Team Blog, http://arcpadteam.blogspot.com/2012/09/user-requested-sample-incrementing-ids.html. I believe the
functionality you desire can be obtained by adjusting the sample to your data and workflow.

Cheers,
Denise
0 Kudos