>>>>>Greetings,
>>>>>
>>>>>I am trying to design a class that contains a text box and a list box. (Similar to the help in windows). I want to be able to type in text in the text box and as the user enters data, I want the list box to select the row that matches.
>>>>>
>>>>>The code below works great as long as the index order matches the record number. When I index a table and set the order, the record number always stays with the record. How do I refer to the correct item in the list when the record number and listindex do not match?
>>>>>
>>>>>Thanks in advance,
>>>>>
>>>>>Scott
>>>>>
>>>>>I am using VFP 3.0b.
>>>>>
>>>>>
>>>>>***Text 1 interactivechange event
>>>>>set exact off
>>>>>seek alltrim(upper(this.value))
>>>>>
>>>>>if found()
>>>>> nRec = recno()
>>>>> this.parent.list1.selected(nRec) = .t.
>>>>>endif
>>>>>
>>>>>this.refresh
>>>>
>>>>Try to set Listbox.Value and then Setfocus:
>>>>
>>>>*** textbox.interactivechange event
>>>>SELECT mycursor
>>>>SEEK ...
>>>>IF FOUND()
>>>> With Thisform.MyListbox
>>>> .Value=mycursor.myfield
>>>> .Setfocus
>>>> Endwith
>>>>ENDIF
>>>>
>>>
>>>I have a similar problem with a listbox. The list contains 5 columns; lastname, firstname, ssn, city, state. The rowsourcetype is 6-fields and the rowsource is the list of the corresponding fields from the table. I also have an option button that allows the user to specify the sort order to be by lastname, ssn or city. How do you correctly update the list and position it so that the record that was selected stays selected even after the order is changed?
>>>
>>>I have tried saving the record numbere before changing the order then going back to it after requerying and refreshing, but I can't seem to get back to the right row in the list.
>>
>>You may apply the same approach: keep listbox.value and reset it after each lisbox.requery
>
>I tried that, but the value returns the contents of the first column in the list which may not be unique.
So, you may set BoundColumn to the column with unique value.
Edward Pikman
Independent Consultant