Select to view content in your preferred language

auto populate a field from another

3063
6
11-10-2010 05:50 AM
markfarina
Emerging Contributor
Hello,

What is the best way to auto-populate a text box with the value from a text box on the previous tab??? Is this possible?

Please see attached picture.  In this example, the user would populate the bottom depth of a soil horizon and when he/she tabs over to the next page...the horizon top depth is auto populated from the bottom depth on the previous tab.

Thanks

APL from H1 tab:

<LABEL name="LABEL29.5" caption="Depths" x="50" y="3" width="35" height="12" tooltip=""/>
<EDIT name="H1TDEPTH" field="H1TDEPTH" x="77" y="2" width="18" height="12" border="true" tabstop="true" tooltip=""/>

<LABEL name="LABEL29" caption="-" x="95" y="3" width="10" height="12" tooltip=""/>

<LABEL name="LABEL29.7" caption="" x="1" y="30" width="45" height="12" tooltip=""/>
<EDIT name="H1BDEPTH" field="H1BDEPTH" x="102" y="2" width="18" height="12" border="true" tabstop="true" tooltip=""/>
Tags (3)
0 Kudos
6 Replies
StevenRehbaum
Emerging Contributor
Munsell soil colors huh?  I understand what you mean, but is it essential?  I believe it's possible to do.  Ahhh...Munsell colors take me back.  Good luck.
0 Kudos
RolfBroch
Frequent Contributor
Usually a control can only get assigned values, when the page to which the control belongs, is active.

You therefore need to write a script that triggers with the page's onsetactive event. This script should fill the editboxes by reading the values from the previous page.

Rolf
0 Kudos
IvanKautter
Regular Contributor
For the onsetactive event for page H2

Dim obj // creates object
Set obj = ThisEvent.Object.Parent // passes object reference for the parent of the page i.e the form
If Not obj.Mode = 1 Then //will not run code if form is pulled up by the identify tool
Dim pPageH1, pPageH2  // creates page variable
Set pPageH1 = ThisEvent.Layer.Forms("EDITFORM").Pages("H1") //sets object reference for page H1
Set pPageH2 = ThisEvent.Layer.Forms("EDITFORM").Pages("H2") //sets object reference for page H2

pPageH2.Controls("H2TDEPTH").Value = pPageH1.Controls("H1BDEPTH").Value //takes the value from one control and puts it in the other

End If


That's it.
0 Kudos
markfarina
Emerging Contributor
I am still learning this and am really stuggling with some of the basic concepts here...

How do I create an onsetactive event for page2 of my form?

I tried inserting....onsetactive="WriteToH2BDepth".... into line one of my form APL below and

Sub WriteToH2Depth 'script from Ivan" End Sub....into the VBS

This didn't work though...Am I on the right track?

Thanks


Here my APL for H2




<PAGE name="PAGE5" caption="H2" backgroundcolor="white">
<LABEL name="LABEL29" caption="H2" x="3" y="3" width="18" height="12" tooltip=""/>
<COMBOBOX name="H2" field="H2" x="16" y="2" width="30" height="12" border="true" tabstop="true" tooltip="" limittolist="false">
<LISTITEM value="Oa" text="Oa"/>
<LISTITEM value="Oe" text="Oe"/>
</COMBOBOX>
<LABEL name="LABEL29.5" caption="Depths" x="50" y="3" width="35" height="12" tooltip=""/>
<EDIT name="H2TDEPTH" field="H2TDEPTH" x="77" y="2" width="18" height="12" border="true" tabstop="true" tooltip=""/>
<LABEL name="LABEL29" caption="-" x="95" y="3" width="10" height="12" tooltip=""/>
<LABEL name="LABEL29.7" caption="" x="1" y="30" width="45" height="12" tooltip=""/>
<EDIT name="H2BDEPTH" field="H2BDEPTH" x="102" y="2" width="18" height="12" border="true" tabstop="true" tooltip=""/>
<LABEL name="LABEL28.5" caption="Texture" x="1" y="19" width="35" height="12" tooltip=""/>
<EDIT name="H2Texture" field="H2Texture" x="30" y="19" width="40" height="12" border="true" tabstop="true" tooltip=""/>
<LABEL name="LABEL29.6" caption="Color" x="1" y="77" width="35" height="12" tooltip=""/>
<EDIT name="H2COLOR" field="H2COLOR" x="21" y="77" width="40" height="12" border="true" tabstop="true" tooltip=""/><LABEL name="LABEL29.9" caption="Note" x="64" y="77" width="25" height="12" tooltip=""/>
<EDIT name="H2NOTE" field="H2NOTE" x="83" y="77" width="40" height="12" border="true" tabstop="true" tooltip=""/>
<BUTTON name="cmdAddB1" x="3" y="92" width="23" height="10" onclick="Call drawto10yr" caption="10YR " tabstop="true" alignment="center"/>....................................etc
0 Kudos
RolfBroch
Frequent Contributor
You should be on the rigth track.

If you create a Sub out of Ivan's code and add onsetactive="Call WriteToH2BDepth()" as in the following example

<PAGE page="page2" onsetactive="Call WriteToH2BDepth()" ...

ArcPad will execute the script when the page is set active.

I like to write "Call WriteToH2BDepth()" but ="WriteToH2BDepth" should work as well.

I did notice though, that there was no page2 or onsetactive in your apl for H2 below.

Rolf
0 Kudos
markfarina
Emerging Contributor
Thanks, I finally got the onsetactive to work!

My mistake was that I did not correctly define (page="page5") in the apl.


Original,

<PAGE name="PAGE5" caption="H2" backgroundcolor="white" onsetactive="Call Ivans code">


Corrected,

<PAGE name="PAGE5" caption="H2" page="page5" backgroundcolor="white" onsetactive="Call Ivans code">

Thanks to everyone.
0 Kudos