airhendrix13

Hi,

I'm trying to link two list boxes. For example, in ListBox1 I have Balances, Centrifuges, and Mixers. Lets say when balances is selected, I want all of the models for balances to appear in ListBox2. All of my data is connected to an Access databse. Also Balances, Centrifuges, and Mixers are worksheets within a workbook and my models are column within balances, centrifuges, etc...

How do I link them

I'm a noob so use small words

Thanks,




Re: Visual Basic General Linking Two List Boxes

michael.f

Ok well i start of by saying i know nothing about programming in databases but i made a program that did a simaler thing.

Ok well basically you need to creat an event to the 1st listbox sumthing like this.

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

ListBox2.Items.Clear()

If Not ListBox1.SelectedIndex = -1 Then

'Fill out the 2nd Listbox Here

ListBox2.Items.Add("")

End If

End Sub

To figure out what to populate in the second ListBox you can find the name of the selected item in the 1st listbox with

ListBox1.SelectedItem

or

ListBox1.SelectedIndex