473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

List box using tables

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
5 2229
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
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
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
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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Not Me | last post by:
Hi, I'm sure this is a common problem.. to create a single field from a whole column, where each row would be separated by a comma. I can do this for a specified table, and column.. and I've...
2
by: Patrick Fisher | last post by:
I am using the following module code to display in a List Box all attached tables that start with tblProducts i.e. tblProductsSpain or tblProductsFrance etc I have other code which enables the...
5
by: Lee Brotzman | last post by:
Hi, I have a sequence of data tables in an ordered list, like this: <ol> <li><table></table></li> <li><table></table></li> </ol> However it renders on the page with the list item number...
4
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one...
7
by: =?Utf-8?B?UmVraGE=?= | last post by:
Hi, I am trying to change the font color for the items in a dropdownlist control at run time using ASP.NET 2.0. DropDownList1.Items.Attributes.Add("style", "color:red"); But when I run the...
5
by: shapper | last post by:
Hello, I have the following list: <ul id="parent" class="parent"> <li> <img... </li> <ul id="child" class="child"> <li>Message 1</li>
2
by: Lysander | last post by:
I have not seen this feature documented before, so I thought I would share it with you, as I will be using it in a later article. For a combo or list box, the source data is normally a...
1
by: raam | last post by:
hi I have a list box with some country names from database. when i click search button the "country" list selecteditem should be selected. but it is not. here is my code where iam using a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.