By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,098 Members | 1,895 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,098 IT Pros & Developers. It's quick & easy.

List box using tables

P: n/a
I have a table called table1 that has a one to many relationship to
table2. What I would like to do is have a form with two list boxes on
it. The first list box will have a field from all of the records in
table1. When the user clicks on one of the records, the second list
box will show all of the records related to that from table2. Is this
possible? How can it be done.

Regards,
Chris Vettese
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Can you use a subform and have the 2nd list box in the subform?

"chris vettese" <ch**********@yahoo.com> wrote in message
news:40**************************@posting.google.c om...
I have a table called table1 that has a one to many relationship to
table2. What I would like to do is have a form with two list boxes on
it. The first list box will have a field from all of the records in
table1. When the user clicks on one of the records, the second list
box will show all of the records related to that from table2. Is this
possible? How can it be done.

Regards,
Chris Vettese

Nov 12 '05 #2

P: n/a
Chris

"chris vettese" <ch**********@yahoo.com> schrieb im Newsbeitrag
news:40**************************@posting.google.c om...
I have a table called table1 that has a one to many relationship to
table2. What I would like to do is have a form with two list boxes on
it. The first list box will have a field from all of the records in
table1. When the user clicks on one of the records, the second list
box will show all of the records related to that from table2. Is this
possible? How can it be done.


you can use the value of listbox1 as criteria for the rowsource of
listbox2

me.mylistbox2.rowsource = "select whatever from table2 where
contentofthefield = " & me.mylistbox1.column(0) or ...any
column-number.

Peter
Nov 12 '05 #3

P: n/a
On 19 Feb 2004 14:12:58 -0800, chris vettese wrote:
I have a table called table1 that has a one to many relationship to
table2. What I would like to do is have a form with two list boxes on
it. The first list box will have a field from all of the records in
table1. When the user clicks on one of the records, the second list
box will show all of the records related to that from table2. Is this
possible? How can it be done.

Regards,
Chris Vettese


Without knowing what is in these tables I can only be general. Set the
rowsource for the first listbox to aquery that returns all the results you
want from table1. Make the bound column of this list box whichever field is
the related one from table2.
In the second list box set the rowsource to a query that returns all the
fields you want "...WHERE (table2.FieldName = forms!FormName!Listbox1);"
If necessary, use the AfterUpdate event of the first listbox to requery the
second. this way each choice in the first, will cause the second to change
its list.
--
Mike Storr
www.veraccess.com
Nov 12 '05 #4

P: n/a
Mike,

I tried your suggested solution and it didn't work. I also tried some
of the other suggestions with out luck. Maybe if I give more details
it will help.

tblPartNumber has a 1 to many relationship with tblTicketNumber

tblPartNumber has the following fields PartID (Auto Number),
PartNumber (Number), Completed (Yes/No)
I made a query from this table called qryPartNumber. The only
criteria is that Completed = No

tblTicketNumber has the following fields TicketID (Auto Number),
TicketNumber (Number), Completed (Yes/No), PartID (Number)
I made a query from this table called qryTicketNumber. The
criteria is that Completed = No and PartID =
[Forms]![frmPartNumber]![PartID]

I created a form called frmPartNumber. On the form are 2 unbound list
boxes. The first listbox has the Row Source as qryPartNumber. The
second list box has the row source as qryTickeNumber. Both list boxes
have column 1 (PartID) as the bound column. On the AfterUpdate Event
for the 1st list box I have Me.Requery.

When the form opens, the 1st list box lists all of the Part ID's from
the query. The second list box shows all of the Part ID's for the
first part number. If I click on the second part ID nothing changes
in the second list box. I have 2 problems: 1 - The second list box
does not update when I choose another part number (I'm not sure how to
requery the qryTicketNumber in code. 2 - I want the part Number and
Ticket Number to show up in the lists boxes, not the ID #'s

Any additional help you can provide would be much appreciated.

Best Regards,
Chris Vettese


Mike Storr <st******@sympatico.ca> wrote in message news:<1n******************************@40tude.net> ...
On 19 Feb 2004 14:12:58 -0800, chris vettese wrote:
I have a table called table1 that has a one to many relationship to
table2. What I would like to do is have a form with two list boxes on
it. The first list box will have a field from all of the records in
table1. When the user clicks on one of the records, the second list
box will show all of the records related to that from table2. Is this
possible? How can it be done.

Regards,
Chris Vettese


Without knowing what is in these tables I can only be general. Set the
rowsource for the first listbox to aquery that returns all the results you
want from table1. Make the bound column of this list box whichever field is
the related one from table2.
In the second list box set the rowsource to a query that returns all the
fields you want "...WHERE (table2.FieldName = forms!FormName!Listbox1);"
If necessary, use the AfterUpdate event of the first listbox to requery the
second. this way each choice in the first, will cause the second to change
its list.

Nov 12 '05 #5

P: n/a

"chris vettese" <ch**********@yahoo.com> wrote in message
news:40**************************@posting.google.c om...
Mike, I created a form called frmPartNumber. On the form are 2 unbound list
boxes. The first listbox has the Row Source as qryPartNumber. The
second list box has the row source as qryTickeNumber. Both list boxes
have column 1 (PartID) as the bound column.
This likely means that the second listbox is not retaining the value you
want. The bound column is what value the listbox will have when a row item
is selected
On the AfterUpdate Event
for the 1st list box I have Me.Requery.
Using Me.Requery will attempt to requery the form not the list box. Use
Me!ListboxName.Requery

When the form opens, the 1st list box lists all of the Part ID's from
the query. The second list box shows all of the Part ID's for the
first part number. If I click on the second part ID nothing changes
in the second list box. I have 2 problems: 1 - The second list box
does not update when I choose another part number (I'm not sure how to
requery the qryTicketNumber in code.
See above note
2 - I want the part Number and Ticket Number to show up
in the lists boxes, not the ID #'s
Then you'll need to adjust the ColumnWidths to show hide the needed
columns from the query.

Mike Storr <st******@sympatico.ca> wrote in message

news:<1n******************************@40tude.net> ...
On 19 Feb 2004 14:12:58 -0800, chris vettese wrote:
I have a table called table1 that has a one to many relationship to
table2. What I would like to do is have a form with two list boxes on
it. The first list box will have a field from all of the records in
table1. When the user clicks on one of the records, the second list
box will show all of the records related to that from table2. Is this
possible? How can it be done.

Regards,
Chris Vettese


Without knowing what is in these tables I can only be general. Set the
rowsource for the first listbox to aquery that returns all the results you want from table1. Make the bound column of this list box whichever field is the related one from table2.
In the second list box set the rowsource to a query that returns all the
fields you want "...WHERE (table2.FieldName = forms!FormName!Listbox1);"
If necessary, use the AfterUpdate event of the first listbox to requery the second. this way each choice in the first, will cause the second to change its list.

Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.