Set selection item for listbox



I want to search a listbox for a term and set the selection to that term:

listbox .l -listvariable foo
pack .l

set foo "John"

set listitem [list John Paul George Ringo]

foreach item $listitem {
.l insert end $item
}

..l selection set [lindex [lsearch -inline [.l get 0 end] "John"]]

This code returns this error:

Error in startup script: bad listbox index "John": must be active,
anchor, end, @x,y, or a number
while executing
".l selection set [lindex [lsearch -inline [.l get 0 end] "John"]]"

Can anyone point me in the right direction?

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
.



Relevant Pages

  • Re: Yes/No Display
    ... Thank you John. ... You can use the format function in the query that is the source for the list box. ... After you modify the source you should then see Yes or No in the listbox for ... "Golfinray" wrote: ...
    (microsoft.public.access.gettingstarted)
  • Re: sending data to multiple people
    ... I have a listbox with Arvin, John, Mary, Daisy ... I click John, ... Arvin Meyer wrote: ...
    (microsoft.public.access.formscoding)
  • Re: datarowview
    ... Thanks John. ... I had tried selectedvalue before as well. ... I even have a textbox that displays the selected item from the listbox and tried substituting it in the query. ... > SQL that's referencing the selected item in the listbox. ...
    (microsoft.public.dotnet.framework)
  • Re: Yes/No Display
    ... John and Golfinray, ... You can use the format function in the query that is the source for the list box. ... After you modify the source you should then see Yes or No in the listbox for ...
    (microsoft.public.access.gettingstarted)