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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default to a selected value on list box

Status
Not open for further replies.

berkelium

Programmer
Aug 3, 2008
2
US
Hi ! trying to auto-select (default to) the first value of List2 after the user selects a value from List1.

Although this works:

Private Sub List1_AfterUpdate()
Me.List2.Requery
Me.List2.Selected(0) = True
End Sub

The first item stays selected and won't let the user select another item on List2 anymore ! Any ideas ?

Thanks for your help !
 
Place on OnClick event. Take out Requery.

Private Sub List1_Click()
Me![List2].Selected(0) = True
End Sub
 
Hi fneily - thanks for your reply ! However, I do need the requery because the contents of List2 are being populated by a query that has the result from List1 as a criteria (which is why I had it on the AfterUpdate event). Maybe there's another way to achieve this ?

Thanks again!
 
Too easy mate,

Leave your code exactly as is, set listbox2 multi select property to Extended.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top