multiple listboxes on one form

T

tgrish

I have three list boxes on one form. When the form opens up, only one list
box is displayed. I would like the second list box to be displayed when the
user makes a single selection in the first listbox and display only the
related records to the selection. The three list boxes represent my one to
many relationships for three tables (i.e. listbox A displays table A (one) -
listbox B displays table B (many for table A and one for table C) - listbox C
displays table C (many for table B).

What is the best method to approach this challenge?
 
J

Jesper F

I have three list boxes on one form. When the form opens up, only one list
box is displayed. I would like the second list box to be displayed when
the
user makes a single selection in the first listbox and display only the
related records to the selection. The three list boxes represent my one to
many relationships for three tables (i.e. listbox A displays table A
(one) -
listbox B displays table B (many for table A and one for table C) -
listbox C
displays table C (many for table B).
What is the best method to approach this challenge?

You need to run code on the listbox's AfterUpdate event.
For example:

Private Sub ListboxA_AfterUpdate()
Dim SQL as string
SQL = "SELECT * FROM tableB WHERE yourfieldname= " & Me!listboxA
Me!listboxB = SQL
Me!listboxB.visible=True
End Sub

And about the same for listboxB and C.


Jesper
 
T

tgrish

Thanks a ton Jesper! I am so embarassed at how easy that was. Leave it up to
me make harder than it needed to be.

Thanks again from an obvious rookie.
 
J

Jesper F

tgrish said:
Thanks a ton Jesper! I am so embarassed at how easy that was. Leave it up
to
me make harder than it needed to be.

Thanks again from an obvious rookie.

You're welcome, glad to help :)


Jesper Fjølner
 
J

Jesper F

By the way that should be:

Me!listboxB.rowsource = SQL

in case you can't get it to work.
 
Top