473,664 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

selecting from combo box to fill list box

107 New Member
Hello,
first problem I am having creating this database is:
Can I create a combo box to select different tables to display in list box?
3 tables
tblGuitar, tblPercussion, tblKeyboards

I want to be able to select Guitar, Percussion, or Keyboard in combo box.
(combo box called cmbOne).
And then in ListBox ( called listOne) have each table display depending on choice selected in combo box.
Thank you,
Apr 5 '09 #1
5 1540
DonRayner
489 Recognized Expert Contributor
You could use the "After Update" event for your combobox to set the rowsource for your listbox. Here is an example of how you could do it.

Expand|Select|Wrap|Line Numbers
  1. Public Sub cmbOne_AfterUpdate()
  2. Dim stSQL as string
  3. Select Case Me.cmbOne
  4. Case is = "Guitar"
  5.     stSQL = "Select tblGuitar.* From tblGuitar;"
  6. Case is = "Percussion"
  7.     stSQL = "Select tblPercussion.* From tblPercussion;"
  8. Case is = "Keyboard"
  9.     stSQL = "Select tblKeyboards.* From tblKeyboards;"
  10. Case Else
  11.     stSQL = ""
  12. End Select
  13. Me.listOne.RowSource = stSQL
  14. End Sub
Apr 5 '09 #2
NeoPa
32,568 Recognized Expert Moderator MVP
If cmbOne had the table names in as the bound column (either by having that as a single column or as a separate bound column) then you could set the RecordSource for the ListBox to something like :
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM [Forms]![FormName].[cmbOne]
You would probably still need the Requery after any selection though (Name of ListBox assumed to be lstTwo) :
Expand|Select|Wrap|Line Numbers
  1. Public Sub cmbOne_AfterUpdate()
  2.   Call Me.lstTwo.ReQuery
  3. End Sub
Apr 5 '09 #3
FishVal
2,653 Recognized Expert Specialist
Hello, buddyr.

Why do you have three different tables. Wouldn't it be more suitable to have only one?

In a case the answer is "because though they share some fields the rest are very different" I could propose you a solution which, IMHO, is much more suitable and more relevant in terms of normalization rules.

Regards,
Fish
Apr 5 '09 #4
buddyr
107 New Member
thank you Don and NeoPa

I will have to read about normilization to understand
Thank you
Apr 5 '09 #5
NeoPa
32,568 Recognized Expert Moderator MVP
I would always recommend that Buddy. It is such a useful thing to understand.
Apr 5 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1354
by: Thomas McK | last post by:
Hi all, I was hoping someone could provide a little direction for me with this problem. I have three reports already made, we'll call them myRpt1, myRpt2 and myRpt3, in my Access db, and I want to be able to fill a combo box on a form with these three values and be able to select one for viewing in this manner. I'm not sure how to bring in each of the reports and treat them as objects for the combo box. Any ideas? Thanks in
4
11789
by: Elena | last post by:
Hi, I am filling in a combobox. I would like to concatenate two fields into the data combo box and display "last name, first name" I tried to displaymember = "employee_last_name" & ", " & "employee_last_name", but it did not like that. I can fill the combo box with either the first or the last, but I cannot manage to concatenate it.
3
4199
by: Bill | last post by:
I have what I think should be a simple question regarding a bound combo box. My first table is Dealers: DealerID - primary key DealerName BillToLocation My second table is Locations: LocationID - primary key LocationDescription DealerID - DealerID of the dealer this location belongs to
4
5099
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I have to load 30,000 unique names into a combox. Filling a dataTable takes only a few milliseconds. But populating the combobox and displaying the list takes several seconds - way too long. A user selects a name from the combobox and runs a query. Originally, this combox was on a form in an MS Access ADP which was linked directly to our sql server. The combobox populated withins millisecnods. How can I achieve this...
2
1448
by: jafarsibtain | last post by:
hi.. I am creating a form where there are two combo Boxes (drop Down) > Program_Combo_box > Course_Code_Combo in the Program Combo Box there are five items in the list > 1. BIT 2.BCA 3. MCA
2
1875
by: Jacko7289 | last post by:
Good Day, My form has two combo boxes where the list of second combo box is dependent on the data chosen from the first combo box. This is how the table (source of data) looks like... Table 1: PROD Prod (PK) Prod_Desc Table 2: PROD_CAT Prod (FK)
5
2069
by: dgardner | last post by:
I have a combo box that lists street numbers. I also have a list box that lists street numbers and addresses (separately). I want to click on one of the street numbers and have the first item in the list box with that street number selected. Any suggestions will be appreciated. Deborah
0
1948
by: Dawnyy | last post by:
I have a form which is bound to a dataset. I am filling the forms dataset on Form_Load event. On my form I have combo boxes which I am setting by running a stored procedure to return a datatable, which I then assign to the datasource. Some of my combo box datasources depend on values in other fields to limit the options. For example, I have a sales rep list that is limited by the customer selected in the customers combo box. And...
0
8438
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
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8779
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
8549
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
7376
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
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
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
2765
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
2
1761
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.