<?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 Re: Lookup Value in DBF Files in ArcPad Questions</title>
    <link>https://community.esri.com/t5/arcpad-questions/lookup-value-in-dbf-files/m-p/356024#M2574</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ivan, thanks for your help. I'm not a programmer and have very limited exerience with Visual Basic. I'm all for making things as simple as possible. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In your last paragraph, you suggested I might be able to simply "get the text from the combo box of the currently selected item and pass that as the value for the text box I am trying to populate".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you know how I could do this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Oct 2010 01:38:18 GMT</pubDate>
    <dc:creator>CharlesHuxtable</dc:creator>
    <dc:date>2010-10-27T01:38:18Z</dc:date>
    <item>
      <title>Lookup Value in DBF Files</title>
      <link>https://community.esri.com/t5/arcpad-questions/lookup-value-in-dbf-files/m-p/356022#M2572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to update the value of a textbox called "txtCommon" based on the value of a Combobox called "cboScientific". I am using ArcPad Studio to design my form.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is almost identical to a request posted to this site by OisinK on 28th April 2010. I have tried the script suggested but it still won't work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The combobox is populated by a dbf file called "NameTest.dbf" with 2 fields - "COMMON" and "SCIENTIFIC".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to attach a function to the onselchange event of "cboScientific" which looks up the corresponding COMMON name in the dbf file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have the following script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sub UpdateCommonName&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim objEditForm, cboSCI, txtCOM, objRecords, dbfSCI, dbfCOM&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set objEditForm = layer.Forms("EDITFORM")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set cboSCI = objEditForm.Pages("Grassnames").Controls("CboGrScientific")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set txtCOM = objEditForm.Pages("Grassnames").Controls("TxtGrCommon")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set objRecords = Application.CreateAppObject("Recordset")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Call objRecords.open("P:\Work\SSD\Users\Huxtac\ArcPad Stuff\Hunter Rapid Survey\GrassNameTest.dbf",1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set dbfSCI = objRecords.fields.item("SCIENTIFIC")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set dbfCOM = objRecords.fields.item("COMMON")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;objRecords.movefirst&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;While not objRecords.EOF&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If cboSCI.Value = dbfSCI.value then &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; txtCOM.Setfocus&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; txtCOM.value = dbfCOM.value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; MsgBox "cboSCI: "&amp;amp; cboSCI &amp;amp; " " &amp;amp; "dbfSCI: " &amp;amp; dbfSCI &amp;amp; " " &amp;amp; "dbfCOM: " &amp;amp; dbfCOM&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End if&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;objRecords.movenext&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;wend&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Sub&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I run this, I can select the scientific name from the combobox list, which works OK, but the Common name textbox is not populated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, in the combobox controls, I have the "Values" field set to "SCIENTIFIC" and the "Text" field set to "COMMON", ie. these are the fields in the dbf file "NameTest.dbf" . Also, I find that if I reverse this and set the "Values" field to "COMMON", and the "Text" field to "SCIENTIFIC", I can selct the common name from the drop-down menu, and the common name textbox is also populated with the common name! (The message box also shows)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone got any ideas??&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Oct 2010 02:16:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/lookup-value-in-dbf-files/m-p/356022#M2572</guid>
      <dc:creator>CharlesHuxtable</dc:creator>
      <dc:date>2010-10-25T02:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup Value in DBF Files</title>
      <link>https://community.esri.com/t5/arcpad-questions/lookup-value-in-dbf-files/m-p/356023#M2573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I might try to confirm that your code can:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Capture and assign the value of the combo box to a variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Connect to, query, and return values from both fields in the dbf&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Assign a value to the text control&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my code I have used the Find method of the recordset object in place of your While loop.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think While...Wend is generally not recommended in VBScript.&amp;nbsp; I would substitute a Do...Loop if you intended to retain that portion of the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In general I would suggest when you get a value from an object such as a combo box or a record from a recordset that you assign that to a variable.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also I would recommend when you get or set of value of a control that you do it more explicitly rather than from a referenced object (e.g. objEditForm.Pages("Grassnames").Controls("CboGrSci entific").Value instead of cboSCI.Value).&amp;nbsp; I can't say why this is a better approach but I think I have experienced some problems getting and setting values of members of an object from a passed reference to an object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also I am not sure why you are using Call objRecords.Open().&amp;nbsp; That may certainly work but I think in general when you use arguments in parenthesis you are asking the method to return a value or object that you will assign to variable or object.&amp;nbsp; I might try this instead:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;objRecords.open "P:\Work\SSD\Users\Huxtac\ArcPad Stuff\Hunter Rapid Survey\GrassNameTest.dbf",1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd also recommend that you close your recordset and set the object reference to it to Nothing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;objRecords.Close&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set objRecords = Nothing&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Additionally, I am a bit confused as to why all this code is necessary.&amp;nbsp; You have a combo box with the scientific name as value and common name as text.&amp;nbsp; Can't you merely get the text from the combo box of the currently selected item and pass that as the value for the text box you are trying to populate?&amp;nbsp; ArcPad is already linked in essence to that dbf table by your populating the combo box with its values.&amp;nbsp; Why requery the values from the dbf when ArcPad already has access to those values and the selected text in the combo box is what you want in the text box?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Oct 2010 15:28:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/lookup-value-in-dbf-files/m-p/356023#M2573</guid>
      <dc:creator>IvanKautter</dc:creator>
      <dc:date>2010-10-25T15:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup Value in DBF Files</title>
      <link>https://community.esri.com/t5/arcpad-questions/lookup-value-in-dbf-files/m-p/356024#M2574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ivan, thanks for your help. I'm not a programmer and have very limited exerience with Visual Basic. I'm all for making things as simple as possible. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In your last paragraph, you suggested I might be able to simply "get the text from the combo box of the currently selected item and pass that as the value for the text box I am trying to populate".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you know how I could do this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Oct 2010 01:38:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/lookup-value-in-dbf-files/m-p/356024#M2574</guid>
      <dc:creator>CharlesHuxtable</dc:creator>
      <dc:date>2010-10-27T01:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup Value in DBF Files</title>
      <link>https://community.esri.com/t5/arcpad-questions/lookup-value-in-dbf-files/m-p/356025#M2575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim strCOM&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;strCOM = cboSCI.Text&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;txtCOM.Value = strCOM&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in place of everything from &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Set objRecords = Application.CreateAppObject("Recordset")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;to&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wend&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In your script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Oct 2010 22:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/lookup-value-in-dbf-files/m-p/356025#M2575</guid>
      <dc:creator>IvanKautter</dc:creator>
      <dc:date>2010-10-28T22:07:28Z</dc:date>
    </item>
  </channel>
</rss>

