473,385 Members | 1,487 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,385 software developers and data experts.

Cascading comboboxes does not allow selection of all values

Hi guys,

I was successful creating two cascading combo boxes according to the instructions in another thread. Here is what I did:

1- I created 3 tables:
table1: farms:
field1: FarmID
field2: FarmName

table2: virtualDBs:
field1: VirtualDBID
field2: VirtualDBInstance

table3: F_VDB:
field1: FarmID
field2: VDBID

table3 is created to show the many-to-many relationship between tables 1 and 2.

2- I created two combo boxes in a form:

combo box1: cboFarm: Column Count = 2
Column Widths = 0;1
Bound Column = 1
Row Source = SELECT farms.FarmID, farms.FarmName FROM farms ORDER BY farms.[FarmName];

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboFarm_AfterUpdate()
  2. Dim strSQL As String
  3.  
  4. strSQL = "SELECT farms.FarmID, VirtualDBs.VirtualDBID, VirtualDBs.VirtualDBInstance FROM VirtualDBs INNER JOIN " & _
  5.          "(farms INNER JOIN F_VDB ON farms.FarmID= F_VDB.FarmID) " & _
  6.          "ON VirtualDBs.VirtualDBID = F_VDB.VDBID WHERE farms.FarmID= " & Me![cboFarm].Column(0)
  7.  
  8. Me![cboVDB].RowSource = strSQL
  9. Me![cboVDB].SetFocus
  10. Me![cboVDB].Dropdown
  11. End Sub

combo box2: Column Count = 3
Column Widths = 0;0;1.5
Bound Column = 1
Row Source = None


cascading two combo boxes and filtreing the second combo box according to the first one works well but the problem is that I cannot select all the values in the second combo box. No matter what I click on, only the very first value gets selected. Any idea why?

Many thanks!
Jun 29 '16 #1

✓ answered by jforbes

I'm pretty sure you want to change the ComboBox2.BoundColumn=2. Right now it is being bound to column 1 which is farms.FarmID which at this point is the same value for all rows because of the WhereClause. So no matter what row you pick, the Value of ComboBox2 is the same as the Value for the first row, so Access displays the first row back to the user.

An alternate way to go about this is to change your select like this:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT VirtualDBs.VirtualDBID, farms.FarmID, VirtualDBs.VirtualDBInstance FROM VirtualDBs INNER JOIN " & _

2 960
jforbes
1,107 Expert 1GB
I'm pretty sure you want to change the ComboBox2.BoundColumn=2. Right now it is being bound to column 1 which is farms.FarmID which at this point is the same value for all rows because of the WhereClause. So no matter what row you pick, the Value of ComboBox2 is the same as the Value for the first row, so Access displays the first row back to the user.

An alternate way to go about this is to change your select like this:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT VirtualDBs.VirtualDBID, farms.FarmID, VirtualDBs.VirtualDBInstance FROM VirtualDBs INNER JOIN " & _
Jun 29 '16 #2
Thank you jforbes, you are a real life saver!
Jun 29 '16 #3

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

Similar topics

3
by: Craig G | last post by:
are there any decent 3rd Party Comboboxes/DropDownLists for ASP.NET that will allow users to enter data into them like in VB.NET? basically i want a combobox that i can populate with a list of...
21
by: raylopez99 | last post by:
Well, contrary to the implication in my 2000 textbook on C# (public beta version), C# does allow multiple inheritance, so long as it's serially chained as follows: class derived02 : derived01 {...
2
by: Jack Russell | last post by:
Just upgrading a VB6 program. I have found allow selection but cannot find out how I find the Selection Buttons value (Checked or not) Any ideas out there? TIA
16
by: Tarheel | last post by:
...You're fast! I appreciate that. Thanks! I look forward to your explanation. One last problem I have on my form is getting all of my comboboxes to update each other. I know how to update...
3
by: AccessBeetle | last post by:
I have a table called tblLocationInfo which has field like I have a form which has a subform and this subform has all these county, township and quad comboboxes based on the look up tables(ex...
3
by: AccessBeetle | last post by:
I have a form which shows a search results based on certain parameters. This form has a subform which has three cascading comboxes, County, Township and Quadmaps. Township and Quadmap should show...
3
by: MOCaseA | last post by:
I have a record lookup form that has several combo box filters set up. However I noticed a slight problem. The filters are working correctly, but there are now over 2000 entries and when filtering...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.