Select to view content in your preferred language

auto-populate records from one feature to another

1989
4
06-15-2011 02:00 PM
JasonTrook
Deactivated User
Hello,

I am trying to autopopulate a form/attribute field from an existing feature but I'm having difficulty  getting my script to do what I want.   My rules are:
1) A user will be capturing a pt feature and collecting some basic info such as recorder name, camera #, and feature type
2) For each day, all attributes will have to be recorded for the 1st pt collected
3) For each day, every time they add a 2nd, 3rd, 4th... pt certain fields (recorder name, camera #) will automatically be loaded into text boxes for these features
4) The process repeats itself the next day

Here is what I have so far:

Option Explicit

Dim strName

Sub getname
Dim objSelLayer, objRS, objEditForm, theEditControl
Set objSelLayer = Map.SelectionLayer
If Map.SelectionLayer Is Nothing Then
  MsgBox "Please select a feature", vbExclamation, Nothing
End If
Set objRS = objSelLayer.Records
objRS.Bookmark = Map.SelectionBookmark
strName = objRS.Fields("Name").Value
msgbox ("Map name is " & strName)
Application.UserProperties("strName") = strName
End Sub


Sub AutoPop
Dim theEditControl
set theEditControl = application.map.SelectionLayer.forms("EDITFORM").pages("Page1").Controls("Name")
theEditControl.value = Application.UserProperties("strName")
End Sub

Thanks,

Jason
Tags (3)
0 Kudos
4 Replies
JasonTrook
Deactivated User
Hi Community,
I'm still struggling to complete this task and any help would be appreciated.  I'm just trying to copy the 'Repeat Attributes' tool in ArcPad but, in my sample, have it copy the first 3 attributes (not the comments field).

Please review my 2 code samples adapted from the forums and my .axf file.  Thanks, Jason

------Sample 1

Option Explicit

' called on on load event
Sub AutoPop
Dim theEditControl
Set theEditControl = application.map.SelectionLayer.forms("EDITFORM").pages("Page1").Controls("ADDRESS")
theEditControl.value = Application.UserProperties("txtAddress")
End Sub

' called on onok event
Dim strName
Sub getname
Dim objSelLayer, objRS
Set objSelLayer = Map.SelectionLayer
If Map.SelectionLayer Is Nothing Then
  MsgBox "Please select a feature", vbExclamation, Nothing
End If
Set objRS = objSelLayer.Records
objRS.Bookmark = Map.SelectionBookmark
strName = objRS.Fields("Address").Value
msgbox ("Address is " & strName)

Application.UserProperties("strName") = strName

End Sub


------Sample 2
Option Explicit

Application.UserProperties("Structures")=""

'called from onok event
Sub RememberEntry
Dim SS
Set SS = Application.Map.Layers.item("Structures").Forms.Item("EditForm").Pages.Item("Page1")
Application.UserProperties("Structures") = SS.controls.item("txtAddress").value

End Sub

'called from onload event
Sub InitializeEditForm
Dim SStm
Set SStm = Application.Map.Layers.item("Structures").Forms.Item("EditForm").Pages.Item("Page1")
If SStm.controls.item("Structures").value= "" Then
SStm.controls.item("Structures").value=Application.UserProperties("Structures")

End If
End Sub
0 Kudos
DouglasBurn
Emerging Contributor
Hi, Jason:

Here is the code I am using to do a similar thing.  The user records initial conditions as attributes for a point feature.  Then they begin capturing vertices for a line feature.  This code gets the starting values from the point feature and uses them to fill in the values for the line feature.  Hope this helps.
0 Kudos
JasonTrook
Deactivated User
Thanks Doug.

I wound up finding a solution.  My code is pretty similar to yours and it captures the starting values from the last point feature and populates it into the next point feature created.

Sub LoadFormFields
   Dim objCnt1,objCnt2,objCnt3,objCnt4,objCnt5,objCnt6,objCnt7,objCnt8,objCnt9,objCnt10,objCnt11  
   Dim objRS_Data1,objRS_Data2,objRS_Data3,objRS_Data4,objRS_Data5,objRS_Data6,objRS_Data7,objRS_Data8,objRS_Data9,objRS_Data10,objRS_Data11
   Dim objLayer,objRS
   Dim fidmin,fidmax

   Set objLayer = Application.Map.Layers("Structures")

   Set objCnt1 = Layer.Forms("EDITFORM").Pages("page1").Controls("txtCountyCityName")
   Set objCnt2 = Layer.Forms("EDITFORM").Pages("page1").Controls("txtDepartmentDistrict")
   Set objCnt3 = Layer.Forms("EDITFORM").Pages("page1").Controls("domEventType")
   Set objCnt4 = Layer.Forms("EDITFORM").Pages("page1").Controls("txtIncidentName")
   Set objCnt5 = Layer.Forms("EDITFORM").Pages("page1").Controls("dtpRecordingDate")
   Set objCnt6 = Layer.Forms("EDITFORM").Pages("page1").Controls("txtDataRecorder")
   Set objCnt7 = Layer.Forms("EDITFORM").Pages("page1").Controls("txtRecordingTeam")
   Set objCnt8 = Layer.Forms("EDITFORM").Pages("page1").Controls("txtPhoneCell")
   Set objCnt9 = Layer.Forms("EDITFORM").Pages("page1").Controls("txtCameraName")
   Set objCnt10 = Layer.Forms("EDITFORM").Pages("page1").Controls("txtGPSName")
   Set objCnt11 = Layer.Forms("EDITFORM").Pages("page1").Controls("txtCityCommunity")

   objLayer.Editable = True
   Set objRS = objLayer.Records

'  Find the record of the last sample entered
   If(objRS.RecordCount > 0) Then
      objRS.MoveFirst
      fidmin = objRS.Fields("OBJECTID").Value 'Object Required error because of this line
     
      While Not objRS.EOF

            objRS_Data1 = objRS.Fields("COUNTYCITYNAME").Value
            objRS_Data2 = objRS.Fields("DEPARTMENTDISTRICT").Value
   objRS_Data3 = objRS.Fields("EVENTTYPE").Value
            objRS_Data4 = objRS.Fields("INCIDENTNAME").Value
            objRS_Data5 = objRS.Fields("RECORDINGDATE").Value
   objRS_Data6 = objRS.Fields("DATARECORDER").Value
            objRS_Data7 = objRS.Fields("RECORDINGTEAM").Value
            objRS_Data8 = objRS.Fields("PHONECELL").Value
   objRS_Data9 = objRS.Fields("CAMERANAME").Value
            objRS_Data10 = objRS.Fields("GPSNAME").Value
            objRS_Data11 = objRS.Fields("CITYCOMMUNITY").Value
            objCnt1.Value = objRS_Data1
            objCnt2.Value = objRS_Data2
            objCnt3.Value = objRS_Data3
            objCnt4.Value = objRS_Data4
            objCnt5.Value = objRS_Data5
            objCnt6.Value = objRS_Data6
            objCnt7.Value = objRS_Data7
            objCnt8.Value = objRS_Data8
            objCnt9.Value = objRS_Data9
            objCnt10.Value = objRS_Data10
            objCnt11.Value = objRS_Data11
    
         objRS.MoveNext
      Wend
   End If
  'Free objects
  Set objRS = Nothing
  Set objLayer = Nothing

End Sub
0 Kudos
StephenGabriel
New Contributor
I do not have coding experience in this but need a function that works exactly like this for a project I am working on.  I have points previously gps'd in two separate feature classes, one for manholes and one for catch basins. I am creating the pipes using a CS25 in the field and it would be helpful if the 'start ID' field and 'end ID' field could be auto-populated based off of the points I snap the line to.  It looks like this srcript Doug has could do the trick but I do not know how to use it on my data with my field names etc.  Could anyone give me a break down of how to enter the code and where I need to make edits?

Thanks
Steve
0 Kudos