Hi there,
I'm trying to display further informations from a dbf-file after a user selected an entries from a combo box. Therefore I start the vbs-script over the onselok in the combo box.
<COMBOBOX name="SPECIES" x="32" y="22" width="94" height="100" defaultvalue="" listtable="species_list.dbf" listvaluefield="SPECIES" listtextfield="SPECIES" onselok="Call UpdateSpeciesList()" tooltip="" tabstop="true" border="true" sip="true" limittolist="false" sort="false" field="SPECIES"/>
In my vbs-File the function looks sofar like that:
Sub UpdateSpeciesList() Dim pForm Set pForm = ThisEvent.Object.Parent pForm.Controls("SPECIES").ListIndex = pForm.Controls("NAME").ListIndex '++ update other information '++ something like Pages("page1").Fields("INFO").Value = xxx Set pForm = Nothing End Sub
For the moment the script just display the name of a species via the ListIndex in a second Combo field called NAME.
Now I want to display additional information from the same DBF entry. For example I have the text-field "INFO" where I want to insert the information form the row INFO. Any idea how I can realize that?
Regards Valentin
Solved! Go to Solution.
Here my solution:
Sub UpdateSpeciesList() Dim pForm Set pForm = ThisEvent.Object.Parent UpdateInfo pForm.Controls("NAME").Value Set pForm = Nothing End Sub '++ insert infos from the table Sub UpdateInfo(output) Dim theControl, allControls, objInfo1, objDBF Set theControl = ThisEvent.Object Set allControls = theControl.Parent.Controls Set objInfo1 = allControls("objInfo1") ' name of the edit field ' load dbf file Set objDBF = CreateAppObject("recordset") objDBF.Open "\Storage Card\My Documents\Liste.dbf", 1 ' 1 = readonly ' move to the begining of the list objDBF.MoveFirst 'loop through DBF list until end of list For i=0 to objDBF.RecordCount-1 If output=objDBF.Fields("NAME").Value then objInfo1.Value = objDBF.Fields("INFO").Value ' INFO is the row we want to insert End If objDBF.MoveNext 'goto next record in DBF table Next objDBF.Close 'close DBF table ' clean up Set theControl = Nothing Set allControls = Nothing Set objInfo1 = Nothing Set objDBF = Nothing End Sub
Don't hesitate to ask if you don't get what I did. I'm not sure if it is the cleanest way to solve the problem, but it works fine for me.
Regards Valentin
Here my solution:
Sub UpdateSpeciesList() Dim pForm Set pForm = ThisEvent.Object.Parent UpdateInfo pForm.Controls("NAME").Value Set pForm = Nothing End Sub '++ insert infos from the table Sub UpdateInfo(output) Dim theControl, allControls, objInfo1, objDBF Set theControl = ThisEvent.Object Set allControls = theControl.Parent.Controls Set objInfo1 = allControls("objInfo1") ' name of the edit field ' load dbf file Set objDBF = CreateAppObject("recordset") objDBF.Open "\Storage Card\My Documents\Liste.dbf", 1 ' 1 = readonly ' move to the begining of the list objDBF.MoveFirst 'loop through DBF list until end of list For i=0 to objDBF.RecordCount-1 If output=objDBF.Fields("NAME").Value then objInfo1.Value = objDBF.Fields("INFO").Value ' INFO is the row we want to insert End If objDBF.MoveNext 'goto next record in DBF table Next objDBF.Close 'close DBF table ' clean up Set theControl = Nothing Set allControls = Nothing Set objInfo1 = Nothing Set objDBF = Nothing End Sub
Don't hesitate to ask if you don't get what I did. I'm not sure if it is the cleanest way to solve the problem, but it works fine for me.
Regards Valentin