Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

selected item in list box set to a newly added row? 1

Status
Not open for further replies.

JGALEY

IS-IT--Management
May 21, 2003
105
US
I have a web form with a listbox, and when I add a record to the DB, I have the listbox cleared and then recreated with the new record included.

How can I have the new record be the selected row of the list box after the add is complete?

Thanks in advance,

Jason
 
With ListBox1
.SelectedIndex = .Items.IndexOf(.Items.FindbyText("MyNewValue")
End With

Hope that helps

Eva
 
Thanks, that put me on the right track! I had to do a

.Items.IndexOf(.Items.FindbyValue(MyVariable)

to make it work the way I wanted, but that really helped me understand what was happening.

Jason
 
make sure you check for when it can't find it in the list.... ie. findbyvalue returns null
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top