Hi folks
I want to update the value of a textbox (i.e. EDIT field) called "txtCOMMON" based on the value of a Combobox called "cboSCIENTIFIC".
The Combobox is populated by a dbf file called "ListSpecies.dbf", with two fields, [SCIENTIFIC] amd [COMMON].
I want to attach a function to the onselchange event of "cboSCIENTIFIC" which looks up the corresponding COMMON name in the dbf file, i.e. return [COMMON] where [SCIENTIFIC]=cboScientific.value.
I am making no headway and would appreciate assistance.
Regards
Oisink
Sub ShowCommonName()
Dim objControl, objPage, objRecords, ScientificName Bookmark
Set objPage = ThisEvent.Object.Parent
'Get cboScientific value
ScientificName = ThisEvent.Object.Value
'Open the dbf
Set objRecords = Application.CreateAppObject("Recordset")
Call objRecords.open("C:\ListSpecies.dbf",1)
'Find the matching item
BookMark = rsAI.Find("[SCIENTIFIC]=""" & ScientificName & """")
'Check for a match
If BookMark = 0 Then
'No match, return the default value
'TODO: is there a valid default value
objPage.Controls("txtCOMMON").Value = ""
Exit Sub
Else
objPage.Controls("txtCOMMON").Value = objRecords.Fields("COMMON").Value
End If
End Sub
Try something like this:
set objFORM = layer.Forms("EDITFORM").controls
set objRecords = Application.CreateAppObject("Recordset")
call objRecords.open("c:\ListSpecies.dbf",1)
objrecords.movefirst
While not objrecords.EOF
if objrecords.fields.item("SCIENTIFIC").value = cboSCIENTIFIC.value then
objForm("txtCOMMON").value = objrecords.fields.item("COMMON").value
end if
objWriteRecords.movenext
Wend
you may need objFORM("txtCOMMON").setfocus in the if then else statement and use objFORM("txtCOMMON").text = "......
Good luck bro.
Hi citrusmosquito
I'm interested in your comment:
[INDENT][/INDENT]"Search "recordset" in the help index for more help"
I have only ArcPad 7.1. No ArcBuilder/ArcStudio etc. I've never been able to find any help or porgramming reference relating to the API, not even an Object Model. I'm probably being dumb, but can you point me in the right direction?
Thanks
Oisin