Select to view content in your preferred language

repeat point attribute based on previous point

917
4
12-21-2010 06:17 AM
markfarina
Emerging Contributor
I would like a button that will auto populate a single field/combobox for a point layer based on the previous point feature attrubute.

For example, if the user knows that the value for a certain field is going to be the same as the  previous waypoints' value, they should be able to just click on a single "repeat" button that will fill that field with the previous points' attribute.  This is more desirable than having to scroll through the list values again and making another selection.

Does anyone have example code for this?  Or ideas on how to do this?

Thanks
Tags (3)
0 Kudos
4 Replies
RolfBroch
Frequent Contributor
In the standard feature property forms in ArcPad 10, there is an toggle button next to the ok and cancel button. When this is pushed in, whenever you create a new feature, it will inherit the values from the last feature. Do a search on "repeated attributes" in the help file for more info.

Rolf
0 Kudos
markfarina
Emerging Contributor
Thanks Rolf...I was aware of this tool, but what I am after is a button on my form that will retrieve the prevous attributes for just a few fields.

My form has many fields and I am afraid the user will become too complacent with the standard 'repeat attributes' tool and allow unrelated data to pass and be saved from one point to the next.  Also, in the woods, from one point to the next, many of the fields on this data collection form do have repeating values...but most do not.

Can anyone suggest how to link a pointlayer form button to its' own dbf and return the last value form one of the fields?

I was attempting to write the code below but my skills at this are pretty crude...I could use some help.

From APL button: "onclick" = Call WriteToRepeatAirPhotoName

VBS:

Sub WriteToRepeatAirPhotoName

Dim myRS, inpath, obj
 
Set Obj = Application.Map.Layers("pointlayer").Forms("EDITFORM").Pages.Item("pgSite")

Set myRS = Application.CreateAppObject("recordset")

inpath = Preferences.Properties("DataPath") & "/"

myRS.Open inpath & "\pointlayer.DBF",2

myRS.MoveLast

myRS.Fields("Airphoto").Value = obj.Controls.Item("Airphoto").Value

End Sub
0 Kudos
GuyBuller
New Contributor
Hi there!

Here is a script that does what I think you would like but only partially. In this case the information is simply copied from the previous record and pasted into a new record. I believe that a file that is in edit mode is not accessible via a recordset for inputting data.

In your case it might have to be a two step process where a menu button is clicked (as in this case from the menu item of our application) and the data can be stored momentarily in a global array and your second step would be when the form that you need is opened it would check to see if the array is populated and then grab the information to fill out those fields that you need.

So instead of populating another recordset (which happens in this script) you would instead populate the controls in the form.

Hope this helps.

Guy


*****************************************************

Sub SameAsBefore(objLayer)
    Dim objRSValues, objRS
    Dim strRecordInfo
    Dim intCounter
    Dim strArray
    Dim intNumFields
    Dim objField
    Dim strFileName
    Dim pPt
    Dim strRSValue
    Dim strLen

    Set objRSValues = Application.CreateAppObject ("RecordSet")
'get the filename to be used for the recordset
strFilename = Replace(Map.Layers(objLayer).filepath,".shp",".dbf")

'get a recordset for the last record information
    Call objRSValues.open  (strFileName,1)

    If (objRSValues.RecordCount < 1) Then
MsgBox " There is no previous record! "
Exit sub
    Else
          objRSValues.MoveLast            ' Go to the end of the recordset
  ' Loop through the collection of fields to build a * delimited string result
  intCounter = 0
         For each objField in objrsValues.fields
  strRSValue = cstr(objField)
  if intcounter= 0 then
   strRecordInfo = strRsValue
  Else
   strRecordInfo = strRecordInfo + "*" + strRSValue
  End If
  intcounter = intCounter + 1
          next        'End While loop when EOF
    objRSValues.close
     End If

    'turn string result into an array
strArray = split(strRecordInfo,"*")

intCounter = 0
  'set the layer to edit mode
  Call SetEditLayer("EARTHMAT")
 
  Set objRS = Application.Map.Layers("EARTHMAT").Records
            Set pPt = Application.CreateAppObject("point")
 
  'set the location of the point
  pPt.y = Application.UserProperties("g_dblYCoord")
  pPt.x = Application.UserProperties("g_dblXCoord")
 
  'add the information derrived from the previous record while the note field is populated with SAB to indicate it is a copy
  objrs.addnew (pPt)
  objrs.fields("Stationid").value = Application.UserProperties("g_strStationID")
  objrs.fields("EarthMatLt").value = "A"
  objrs.fields("EarthMatNo").value = cdbl(strArray(2))
  objrs.fields("EarthMatId").value = Application.UserProperties("g_strStationID")+"A" 
  objrs.fields("Lithgroup").value = strArray(4)  
  objrs.fields("LithType").value = strArray(5)  
  objrs.fields("LithDetail").value = strArray(6)
  objrs.fields("MapUnit").value = strArray(7)
  objrs.fields("unitno").value = strArray(8)  
  objrs.fields("matrixmod").value = strArray(9)
  objrs.fields("matrix").value = strArray(10)
  objrs.fields("jointing").value = strArray(11)  
  objrs.fields("compaction").value = strArray(12)  
  objrs.fields("oxidation").value = strArray(13)  
  objrs.fields("h2ocontent").value = strArray(14)  
  objrs.fields("fissility").value = strArray(15)  
  objrs.fields("hclreact").value = strArray(16)  
  objrs.fields("clastmodal").value = strArray(17)  
  objrs.fields("clastmin").value = strArray(18)  
  objrs.fields("clastmax").value = strArray(19)  
  objrs.fields("clastpct").value = strArray(20)  
  objrs.fields("clastform").value = strArray(21)  
  objrs.fields("sorting").value = strArray(22)  
  objrs.fields("modalrnd").value = strArray(23)  
  objrs.fields("maxround").value = strArray(24)  
  objrs.fields("minround").value = strArray(25)  
  objrs.fields("thicktype").value = strArray(26)  
  objrs.fields("thickmin").value = strArray(27)  
  objrs.fields("thickmax").value = strArray(28)  
  objrs.fields("colour").value = strArray(29) 
  objrs.fields("lwrcontact").value = strArray(30)  
  objrs.fields("intcontact").value = strArray(31)  
  objrs.fields("latcontact").value = strArray(32)  
  objrs.fields("erratictyp").value = strArray(33)  
  objrs.fields("scndstruc").value = strArray(34)  
  objrs.fields("wayup").value = strArray(35)  
  objrs.fields("notes").value = "[SAB]"  
  objrs.fields("interp").value = strArray(37)  
  objrs.fields("interpconf").value = strArray(38)  
  
  objrs.update
 
msgbox " An EarthMaterial SAB has been added to your data."
Application.UserProperties("g_strEarthMatID") = Application.UserProperties("g_strStationID")+"A"
Call EnableButtons
    Set objRS = Nothing
End Sub
0 Kudos
GordonGraham
New Contributor
This thread has been very helpful for me. I also wished to retain certain attributes (which did not change between features) when capturing points using a custom form. The Repeated Attributes Tool in ArcPad was exactly what I needed. Thanks to everyone who has posted.
0 Kudos