<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic put stored variable in form field in ArcPad Questions</title>
    <link>https://community.esri.com/t5/arcpad-questions/put-stored-variable-in-form-field/m-p/610266#M4406</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I have a form with 4 pages. On page 2, I have a combobox that is tied to an external DBF table with 3 fields (code, obs, and test). When the user selects an item from the list, the DBF table's code value is stored in the combobox. Now I have a textbox on page 4 that I want to be autopopulated with a value based on the combobox's selected item. So if a single record in the DBF table is CP, CarPatrol, Test1 then when the user selects CP (code field) for the combobox, I want Test1 (test field) to autopopulate in the textbox on page 4. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am able to open the DBF table, find the record based on the combobox entry and store the "CP" and "Test1" values into variables and display them in a messagebox, but I can't get "Test1" to show up in the textbox. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following code is what I have so far. It is being called from the combobox's OnSelChanged event.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions on what I'm missing?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Charlotte&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Option Explicit

'autopopulate a second field based on entry in first field
Sub AutoPop
Dim objDBF, strCode, strTest, i , strObs, strLoc
 strObs= Layers("camera_stn.shp").Forms("EDITFORM").Pages("PAGE2").Controls("obs").value&amp;nbsp;&amp;nbsp;&amp;nbsp; 'user selected combo box 
 strLoc= Map.Layers("camera_stn.shp").Forms("EDITFORM").Pages("PAGE4").Controls("loc_desc").value&amp;nbsp;&amp;nbsp;&amp;nbsp; 'autopopulate this field based on combo box selection

Set objDBF = Application.CreateAppObject("recordset")&amp;nbsp;&amp;nbsp; 
 objDBF.Open "L:\GPS\Trimble_base\luObsTest.dbf", 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 'open the external DBF table used for combobox list
 objDBF.MoveFirst&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'go to first record in DBF table
For i=0 to objDBF.RecordCount-1
 strCode = objDBF.Fields("CODE").Value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'store value from CODE field
 strTest= objDBF.Fields("TEST").Value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'store value from TEST field
 If strObs=strCode then&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'compare value user selected from combobox list to the 1st CODE value from the DBF table
&amp;nbsp; strLoc=strTest&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'if 1st CODE value = user selection then put the TEST value in the textbox on page 4...
 Else&amp;nbsp; 
&amp;nbsp; objDBF.MoveNext&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '...otherwise go to the next record in the DBF table
 End If

Next
 msgbox ("CODE = " &amp;amp; strCode &amp;amp; vbnewline &amp;amp; "TEST = " &amp;amp; strLoc)&amp;nbsp;&amp;nbsp; 'message box returns DBF values being stored as variables
&amp;nbsp;&amp;nbsp; 
objDBF.Close&amp;nbsp; 

Set objDBF = Nothing 

End Sub&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Apr 2010 02:18:19 GMT</pubDate>
    <dc:creator>CharlottePeters</dc:creator>
    <dc:date>2010-04-20T02:18:19Z</dc:date>
    <item>
      <title>put stored variable in form field</title>
      <link>https://community.esri.com/t5/arcpad-questions/put-stored-variable-in-form-field/m-p/610266#M4406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I have a form with 4 pages. On page 2, I have a combobox that is tied to an external DBF table with 3 fields (code, obs, and test). When the user selects an item from the list, the DBF table's code value is stored in the combobox. Now I have a textbox on page 4 that I want to be autopopulated with a value based on the combobox's selected item. So if a single record in the DBF table is CP, CarPatrol, Test1 then when the user selects CP (code field) for the combobox, I want Test1 (test field) to autopopulate in the textbox on page 4. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am able to open the DBF table, find the record based on the combobox entry and store the "CP" and "Test1" values into variables and display them in a messagebox, but I can't get "Test1" to show up in the textbox. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following code is what I have so far. It is being called from the combobox's OnSelChanged event.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions on what I'm missing?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Charlotte&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Option Explicit

'autopopulate a second field based on entry in first field
Sub AutoPop
Dim objDBF, strCode, strTest, i , strObs, strLoc
 strObs= Layers("camera_stn.shp").Forms("EDITFORM").Pages("PAGE2").Controls("obs").value&amp;nbsp;&amp;nbsp;&amp;nbsp; 'user selected combo box 
 strLoc= Map.Layers("camera_stn.shp").Forms("EDITFORM").Pages("PAGE4").Controls("loc_desc").value&amp;nbsp;&amp;nbsp;&amp;nbsp; 'autopopulate this field based on combo box selection

Set objDBF = Application.CreateAppObject("recordset")&amp;nbsp;&amp;nbsp; 
 objDBF.Open "L:\GPS\Trimble_base\luObsTest.dbf", 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 'open the external DBF table used for combobox list
 objDBF.MoveFirst&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'go to first record in DBF table
For i=0 to objDBF.RecordCount-1
 strCode = objDBF.Fields("CODE").Value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'store value from CODE field
 strTest= objDBF.Fields("TEST").Value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'store value from TEST field
 If strObs=strCode then&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'compare value user selected from combobox list to the 1st CODE value from the DBF table
&amp;nbsp; strLoc=strTest&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'if 1st CODE value = user selection then put the TEST value in the textbox on page 4...
 Else&amp;nbsp; 
&amp;nbsp; objDBF.MoveNext&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '...otherwise go to the next record in the DBF table
 End If

Next
 msgbox ("CODE = " &amp;amp; strCode &amp;amp; vbnewline &amp;amp; "TEST = " &amp;amp; strLoc)&amp;nbsp;&amp;nbsp; 'message box returns DBF values being stored as variables
&amp;nbsp;&amp;nbsp; 
objDBF.Close&amp;nbsp; 

Set objDBF = Nothing 

End Sub&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Apr 2010 02:18:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/put-stored-variable-in-form-field/m-p/610266#M4406</guid>
      <dc:creator>CharlottePeters</dc:creator>
      <dc:date>2010-04-20T02:18:19Z</dc:date>
    </item>
    <item>
      <title>put stored variable in form field</title>
      <link>https://community.esri.com/t5/arcpad-questions/put-stored-variable-in-form-field/m-p/610267#M4407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The problem is you're only storing the VALUE of the text box to strLoc. So if it's blank, (because the user hasn't gotten to that page yet) you're setting the value of strLoc to "". Then down in the for loop you're setting the value of strLoc to strTest, but there isn't any code setting the value of the text box on page 4 to that value. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd replace:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;strLoc=strTest&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;with &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Map.Layers("camera_stn.shp").Forms("EDITFORM").Pages("PAGE4").Controls("loc_desc").value = strTest&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and see if works. Hope this helps!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Apr 2010 18:57:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/put-stored-variable-in-form-field/m-p/610267#M4407</guid>
      <dc:creator>EricHajek</dc:creator>
      <dc:date>2010-04-21T18:57:52Z</dc:date>
    </item>
    <item>
      <title>put stored variable in form field</title>
      <link>https://community.esri.com/t5/arcpad-questions/put-stored-variable-in-form-field/m-p/610268#M4408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the suggestion. I tried the code change, but it didn't quite work. As a test, I put a msgbox outside the loop to catch the value that is suppose to populate the textbox and it did return the correct value, but it didn't show up on the form. I don't have any 'read-only' or other restrictions on either of the controls. I ended up taking the code away from the combobox and put it on the 'onsetfocus' event of the PAGE4 textbox. So now the user selects a value for the combobox, goes to PAGE4, taps the textbox and the value associated with the combobox is entered. The only drawback is that the user has to go back to the textbox everytime they update the combobox, but it works otherwise. The code below works for now. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, Charlotte&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Option Explicit

'autopopulate a field based on entry in another field
Sub AutoPop
Dim objDBF, strCode, strTest, i , strObs
 strObs= Layers("camera_stn.shp").Forms("EDITFORM").Pages("PAGE2").Controls("obs").value 'get value user selected in obs field
Set objDBF = Application.CreateAppObject("recordset")&amp;nbsp;&amp;nbsp; 
 objDBF.Open "L:\GPS\Trimble_base\luObs.dbf", 1&amp;nbsp; 'open the external DBF table
 
 objDBF.MoveFirst 
For i=0 to objDBF.RecordCount-1&amp;nbsp;&amp;nbsp; 'loop through DBF list until end of list 

 If strObs=objDBF.Fields("CODE").Value then 'compare selected obs value form with 1st CODE value from table
&amp;nbsp; strTest = objDBF.Fields("TEST").Value 'if form value = CODE value then store associated TEST value in variable
&amp;nbsp; ThisEvent.Object.value=strTest&amp;nbsp;&amp;nbsp; 'enter stored variable into text box on form
 Else&amp;nbsp; 
 End If
 objDBF.MoveNext&amp;nbsp; 'goto next record in DBF table
Next
 objDBF.Close&amp;nbsp;&amp;nbsp;&amp;nbsp; 'close DBF table

Set objDBF = Nothing 

End Sub&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:06:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/put-stored-variable-in-form-field/m-p/610268#M4408</guid>
      <dc:creator>CharlottePeters</dc:creator>
      <dc:date>2021-12-12T02:06:40Z</dc:date>
    </item>
    <item>
      <title>follow up</title>
      <link>https://community.esri.com/t5/arcpad-questions/put-stored-variable-in-form-field/m-p/610269#M4409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just to follow up. I was working on another form with a similar problem to the one I initially posted where I can't get a stored variable to "stick" in another field. I think page activation may have something to do with it. I notice that if I assign a stored variable to a control on the first page, which by default is activated when the form loads, then I can see the value in the control. However, if I assign the stored variable to a control on another (not active) page then the control remains blank. I found that the following sequence works if I need to assign a stored variable on a page other then the currently active page.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;run the code I need to get a value stored in a variable&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;make the page that contains the control I need active using code something like: &lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;Application.Map.Layers("camera_stn.shp").Forms("EDITFORM").Pages("PAGE4").Activate&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;enter the stored variable into the desired control using code something like:&amp;nbsp; &lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;Application.map.Layers("camera_stn.shp").Forms("EDITFORM").pages("PAGE4").controls("obs").value=StoredVariable&lt;/PRE&gt;&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;make the first page active again so user can start data entry&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;SPAN&gt;The process of activating PAGE4, entering the value and reactivating PAGE1 happens really fast so the user isn't left wondering why the pages are out of order.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I should also note that I am modifying the forms/code ArcPad8 Studio and using the files in ArcPad 7.1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Charlotte&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Apr 2010 23:59:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/put-stored-variable-in-form-field/m-p/610269#M4409</guid>
      <dc:creator>CharlottePeters</dc:creator>
      <dc:date>2010-04-22T23:59:15Z</dc:date>
    </item>
  </channel>
</rss>

