473,675 Members | 3,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2249
Can you use a subform and have the 2nd list box in the subform?

"chris vettese" <ch**********@y ahoo.com> wrote in message
news:40******** *************** ***@posting.goo gle.com...
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**********@y ahoo.com> schrieb im Newsbeitrag
news:40******** *************** ***@posting.goo gle.com...
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.r owsource = "select whatever from table2 where
contentofthefie ld = " & me.mylistbox1.c olumn(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.FieldNa me = 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******@sympa tico.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.FieldNa me = 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**********@y ahoo.com> wrote in message
news:40******** *************** ***@posting.goo gle.com...
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******@sympa tico.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.FieldNa me = 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
9892
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 created a function using VBA to achieve a more dynamic (and very slow) solution.. so I would like to implement it using a user defined function in sql server. The problems I'm facing are, that I can't use dynamic sql in a
2
7867
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 user to enter a new table name, the code then creates the table in the attached back end database and automatically links it to the front end. My problem is that the list box does not display the new tables until I close the program and restart...
5
14178
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 next to the
4
64598
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 determines the available options in the other. TERMINOLOGY Row Source: The table/query from which the Combo Box or List Box gets its values. Note: There are other types of row sources that can be used but for simplicity we will stick with Tables...
7
17426
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 application, I don't see any color change. I am using Visual Studio 2005, ASP.NEt 2.0.
5
2177
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
6229
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 Table/Query. Or it could be a value list, a static list of data. But what if your information is not held in a table, and it is not a static list. Examples I have used have been, “next 100 prime numbers after this one”, “Every third Friday from start of...
1
1568
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 stored procedure which is outputting 3 tables simultaneously. the list box of country is 3rd table that is table if (objDataSet.Tables.Rows.Count > 0) {
0
8521
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8867
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8680
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8722
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7501
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4261
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2867
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.