1

I am trying to add a button to an ArcPad form that sets the values to Cereal and Corn. This is as far as I have gotten and I am stuck.


I Made apl that has a form. I get the values into the form using the arcpad data manager from ArcMap. it populates the form giving me combo boxes. What I need is a button that will make it easier to choose specific values from the combo boxes. So instead of scrolling down the combo boxes to make my choice and hitting OK. I want to just hit the corn button and then that updates the combo boxes and adds the form and closes it. In the image you can understand what it is I need to do. This is for field work and the easier it is to insert some crop types the faster it gets done.

'once called updates the fields to add in corn to the form then closes the form
Sub InsertCorn(ByVal layerName, ByVal pageName)

   Dim objEditForm
   Dim objTheLayer 
   Dim objEFPageControls
   Set objTheLayer = Application.Map.Layers.item(layerName)
   Set objEditForm = objTheLayer.Forms(1)
   Set objEFPageControls= objEditForm.Pages(pageName).Controls

   objEFPageControls("cboAGRLU_ClassGRP").value = "Cereal"
   objEFPageControls("cboCropType_Varietal").value = "Corn"

   Set objEFPageControls= Nothing
   Set objEditForm = Nothing
   Set objTheLayer = Nothing
End sub

then in the onclick event on the button:

  Call InsertCorn("Corn", "PAGE1")

ArcPad Form

  • It is not clear what you are trying to say. Is this a Sub that is called by an onClick event? You say sets the value, value of what? What type of control is cboAGRLU_ClassGRP? Please update your question. – Hornbydd Nov 18 '14 at 20:57
  • I updated the question – abhinav sharma Nov 19 '14 at 12:37
1

You need to reference the ArcPad layer name that you are applying the value update to and call your Sub via onClick event per @Hornbydd comment, see example code below:

Sub InsertCorn(ByVal layerName, ByVal pageName)

  Dim objEditForm, objTheLayer, objEFPageControls
  Set objTheLayer = Application.Map.Layers.item(layerName)
  Set objEditForm = objTheLayer.Forms(1)
  Set objEFPageControls= objEditForm.Pages(pageName).Controls

  objEFPageControls("cboAGRLU_ClassGRP").value = "Cereal"
  objEFPageControls("cboCropType_Varietal").value = "Corn"

  Set objEFPageControls= Nothing
  Set objEditForm = Nothing
  Set objTheLayer = Nothing

End Sub
| improve this answer | |
  • Oh I thought since there is only one form and one page that it would know. Also by calling it via sub what is it that you mean? Inside the button I have it calling InsertCorn on the OnClick command. Also what would i insert for layername? – abhinav sharma Nov 20 '14 at 12:39
  • 1
    @abhinav sharma, The name of the layer that is related to your form in ArcPad. For example, my sub example is passing in the layeName and pageName as arguments. – artwork21 Nov 20 '14 at 13:16
  • So when i call insert corn from the onclick command i would do it as Call InsertCorn(corn,Page1)? I will try it out thank you – abhinav sharma Nov 20 '14 at 14:52
  • 1
    Yes, I believe you will need double quotes around those two, e.g. ("corn","Page1") – artwork21 Nov 20 '14 at 16:02
  • using this method I am getting a runtime error. with the message being "Object required: 'objTheLayer'" at the line where it sets objthelayer – abhinav sharma Nov 20 '14 at 16:07
0

Finally have it working error free. This is the finished code. Seems to do all that i as for it. Thank you very much artwork21 for all your help.

Sub InsertCrop(Byval className, Byval cropName)
  Dim objEditForm
  Dim objTheLayer 
  Dim objEFPageControls
  Set objTheLayer = Application.Map.Layers.item("STB_EOS_DCT")
  Set objEditForm = objTheLayer.Forms("EDITFORM")
  Set objEFPageControls= objEditForm.Pages("PAGE1").Controls

  objEFPageControls("cboAGRLU_ClassGRP").value = className
  objEFPageControls("cboCropType_Varietal").value = cropName
  objEFPageControls("txtFIELDNOTES").value = ""

 objEditForm.Close(True)
 Set objEFPageControls= Nothing
 Set objEditForm = Nothing
 Set objTheLayer = Nothing

End sub
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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