Listbox, setting selected item

  • Thread starter Thread starter Steve Schroeder
  • Start date Start date
S

Steve Schroeder

I'm trying to progammatically select an item in a query bound listbox
without actually knowing the ListIndex value. I do however know the value of
the bound column. I thought all you had to do was:

lstInventors.Requery
lstInventors.Value = lInv

Where lInv is a long value representing the primary key, a hidden column
(width = 0')

Nevertheless...nothing appears to be selected or hightligted, except the
first row of the listbox.

Thoughts? Ideas?

Thanks
 
Providing that you're talking about a list with no multiselect, then it's
just lstInventors=lInv
 
Yes, that would be what I'm trying to do. Unfortuantely it doesn't seem to
work. Although I can replicate (mostly) the functionality I want on a
different form and get the expected behavior.

After I set the value of the listbox to the desired value (bound column) no
item in the list is 'selected' although the value does return (in a msgbox)
the expected value.

This is a databound listbox that I'm first adding a record to, requerying ,
then I want to bring the user to that record (switching from one tab to
another in a tab control).

I suspect a series of events are conspiring against me (literally). I may
just have to redesign a bit, but if anyone has any suggestions I would love
to hear them, thanks!
 
The answer:

Dim lInv As Long

lInv = SaveNewInventor '<---Returns bound column (primary key)
lstInventors.RowSource = "Select fldInventorID, fldFullName, fldLastName,
fldFirstName, fldMiddleInit, fldStreet, fldInvCity, fldInvStateID,
fldInvZip, fldCountryID, fldPhoneNum, fldFaxNum, fldInvCorpStateID,
fldInvResStateID, fldModifyUser, fldDateModified From tblInventors Order By
fldLastName"
lstInventors.Value = lInv
pgInventors.Visible = True
pgInventors.SetFocus
lstInventors_AfterUpdate

Resetting the Rowsource has the same effect as Requery, without resetting
the Index value of the selected item. Hoo-Yah.
 
Back
Top