Select to view content in your preferred language

Clone method

1494
1
10-29-2010 01:34 AM
XavierLegrain
New Contributor
Hi,

I'm quite beginner with ArcPad Studio... Here are 2 problems with my codes. Help and advices are welcome (I'm using ArcPad 8.0)

1/ I would like to duplicate a point whish is selected on my map. Here is my code (whish doesn't work) :

Sub DuplicatePoint
Dim objSelLayer, objRS
Set objSelLayer = Application.Map.SelectionLayer
'Quitter si pas de points sélectionnés
If objSelLayer Is Nothing Then
MsgBox "Aucun point n'a été sélectionné",vbExclamation,"Aucune sélection"
Exit Sub
End If
'Identifier le point sélectionné
Set objRS = objSelLayer.Records
objRS.Bookmark = Application.Map.SelectionBookmark
'Dupliquer le point
objRS.Clone
objRS.Update
Application.Map.Redraw(True)
End Sub

2/ When I click "OK" after writing informations on a form linked with a shapefile, I would like to change the value of the field "Etat" for the selected feature. Here is my code (whish run after the "onok" event of my form) :

Sub ChangeSymbolColor
Dim objSelLayer, objRS
Set objSelLayer = Application.Map.SelectionLayer
Set objRS = objSelLayer.Records
objRS.Bookmark = Application.Map.SelectionBookmark
objRS.Fields("Etat").Value = 1
objRS.Update
Application.Map.Redraw(True)
End Sub

Thank for help.

Xavier Legrain
Tags (3)
0 Kudos
1 Reply
EricHajek1
Regular Contributor
1
There isn't a .Clone method for recordsets unfortunately, so I think you'd have to copy the values of the fields to variables, then copy them back to a new record within the recordset, after creating a new record with the .AddNew method.

2
I don't know why the code here isn't working, I don't mess with recordsets very much, but you might try this in the "onunload" (not sure if it works with "onOK", but it might) event of your form:

ThisEvent.Object.Fields("Etat").value = 1

ThisEvent.Object gets a reference to the form (if fired from a form's event), and from there you can access the form's fields.

You could then put the Application.Map.ReDraw(True) in the onKillActive event of the form.

Hope this helps!
0 Kudos