multiple listboxes on one form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
 
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.
 
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
 
By the way that should be:

Me!listboxB.rowsource = SQL

in case you can't get it to work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top