Select to view content in your preferred language

DefaultValue property not working with text

733
2
05-07-2012 11:58 AM
BillTrask
Deactivated User
I have a form that contains 4 buttons and a text box.  When I click a button, text is written to the test box.  To save time, I'd like the text to be remain within the text box upon opening the form. DefaultValue property within the controls object an easy fix, right? Nope. The text isn't retained within the text box; however, a number is retained (for example, replacing the "Wetlands" with 9).  The code below is set to run for the onclick event:

Dim objFrmCtls
Set objFrmCtls = Application.Map.Layers("ESCP").Forms("EDITFORM").Pages("FeatureType").Controls
objFrmCtls("Other").Value = "Wetland"

Dim ObjDefVal
Set ObjDefVal = Application.Map.Layers("ESCP").Forms("EDITFORM").Pages("FeatureType").Controls
objDefVal("Other").DefaultValue = "Wetland"

Any ideas?
Tags (3)
0 Kudos
2 Replies
GarethWalters
Deactivated User
Hi Bill,

Is it possible that you can use the Repeat attributes button? Just wondering if you could achieve this without any code, and make some potential changes to the mxd. If you set the layer symbology in ArcMap to be a unique value based on the text field you will get a seperate icon on the quick capture for the four different types. When you click on the quickcapture icon it will already populate the text box with the correct value.

If that is the only thing you are doing on the form, you could also press the repeat attributes button and go to the table of contents and for the layer un-tick the form check box (if it doesn't have required fields). This way you will be collecting the data without the form popping up.

Now I know that was a side step but just wanted to float the idea.

If you stick to code you can change set the value to an application.userproperties() value. This will set a global variable that you can call again after you open the form of a new/existing feature.

Application.UserProperties("DefaultValue") = Application.Map.Layers("ESCP").Forms("EDITFORM").Pages("FeatureType").Controls
objFrmCtls("Other").Value = "Wetland"

Let us know how you go.

Cheers,

Gareth

0 Kudos
BillTrask
Deactivated User
Thank you for the multiple suggestions, Gareth! I'm partial to the third route since I do wish to have some required fields, additional pages, and prefer the control that comes with coding (plus coding makes me feel smarter!). Being an ArcPad novice, I will certainly explore the first two options.

Application.UserProperties("DefaultValue") = Application.Map.Layers("ESCP").Forms("EDITFORM").Pages("FeatureType").Controls
objFrmCtls("Other").Value = "Wetland"
I did try the ^suggested^ to no avail; that is, it will write "Wetland" to the "Other" attribute for the point being created, but the default attribute for "Wetland" is not carried over into the "Other" text box when the form is subsequently activated.

The Repeat Attributes button also failed to keep the "Wetland" text. Here is what I have for the onclick event of my button:
Dim objFrmCtls
Set objFrmCtls = Application.Map.Layers("ESCP").Forms("EDITFORM").Pages("FeatureType").Controls

Application.UserProperties("DefaultValue") = Application.Map.Layers("ESCP").Forms("EDITFORM").Pages("FeatureType").Controls
objFrmCtls("Other").Value = "Wetland"

Am I forgetting something?


Thank You,
-Bill
0 Kudos