Hello all,
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.
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.
The combobox is populated by a dbf file called "NameTest.dbf" with 2 fields - "COMMON" and "SCIENTIFIC".
I want to attach a function to the onselchange event of "cboScientific" which looks up the corresponding COMMON name in the dbf file.
I have the following script:
Sub UpdateCommonName
Dim objEditForm, cboSCI, txtCOM, objRecords, dbfSCI, dbfCOM
Set objEditForm = layer.Forms("EDITFORM")
Set cboSCI = objEditForm.Pages("Grassnames").Controls("CboGrScientific")
Set txtCOM = objEditForm.Pages("Grassnames").Controls("TxtGrCommon")
Set objRecords = Application.CreateAppObject("Recordset")
Call objRecords.open("P:\Work\SSD\Users\Huxtac\ArcPad Stuff\Hunter Rapid Survey\GrassNameTest.dbf",1)
Set dbfSCI = objRecords.fields.item("SCIENTIFIC")
Set dbfCOM = objRecords.fields.item("COMMON")
objRecords.movefirst
While not objRecords.EOF
If cboSCI.Value = dbfSCI.value then
txtCOM.Setfocus
txtCOM.value = dbfCOM.value
MsgBox "cboSCI: "& cboSCI & " " & "dbfSCI: " & dbfSCI & " " & "dbfCOM: " & dbfCOM
End if
objRecords.movenext
wend
End Sub
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.
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)
Anyone got any ideas??