473,396 Members | 2,147 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,396 software developers and data experts.

How to get cascading combo boxes to work

167 100+
I have 2 combo boxes: 'Division' and 'location'. I want to select a 'division' and have the locations associated with that division be the rowsource for the 'location' combo box (limit the list).
This is for same table source data, table "DivLoc", columns: are DivLocID, Division, Location

Division combo box: cmbDivsion
I have the property for record source set as a query. This query gives the distinct values for divison. This combo box lists the correct results.

Location combo box: cmbLocation
On the 'after update' event of cmbDivision, I have put in the following code:
cmbLocations.RowSource = "SELECT DL.[Location] FROM DivLoc DL WHERE DL.Division = '" & cmbDivisions.value & "' order by DL.Location"
I do not get any values returned in the locations combo box. However, I can run the select statement alone and I get values. I can not figure out what I am doing wrong to prevent the locations values from being displayed as the rowsource.
Any suggestions would be appreciate. I have look at several posts on this forum and it looks like I have followed the same method.
Sep 22 '10 #1

✓ answered by OldBirdman

Have you tried to see what works in the RowSource?
For example, your RowSource is:
Expand|Select|Wrap|Line Numbers
  1. cmbLocations.RowSource = "SELECT DL.[Location] FROM DivLoc DL WHERE DL.Division = '" & cmbDivisions.value & "' order by DL.Location"
Try(1) replace 'V3' with a valid division:
Expand|Select|Wrap|Line Numbers
  1. cmbLocations.RowSource = "SELECT DL.[Location] FROM DivLoc DL WHERE DL.Division = 'V3' order by DL.Location"
Try(2):
Expand|Select|Wrap|Line Numbers
  1. cmbLocations.RowSource = "SELECT DL.[Location] FROM DivLoc DL WHERE DL.Division = '" & "V3" & "' order by DL.Location"
Try(3):
Expand|Select|Wrap|Line Numbers
  1. cmbLocations.RowSource = "SELECT DL.[Location] FROM DivLoc DL WHERE DL.Division = '" & [cmbDivisions] & "' order by DL.Location"
All this assumes your DefaultView is 'Single Form' and not 'Continuous Forms'

6 1549
Mariostg
332 100+
It could be a problem related to the Column Count or Column width properties of the combo box.
Sep 22 '10 #2
gnawoncents
214 100+
Something else you could try is modifying the after update or on change to simply

Expand|Select|Wrap|Line Numbers
  1. cmbLocation.Requery
  2.  
and put the following code in your row source for cmbLocation

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT DivLoc.Location FROM DivLoc WHERE (((DivLoc.Division) Like [cmbDivision])); 
  2.  
Sep 22 '10 #3
OldBirdman
675 512MB
Have you tried to see what works in the RowSource?
For example, your RowSource is:
Expand|Select|Wrap|Line Numbers
  1. cmbLocations.RowSource = "SELECT DL.[Location] FROM DivLoc DL WHERE DL.Division = '" & cmbDivisions.value & "' order by DL.Location"
Try(1) replace 'V3' with a valid division:
Expand|Select|Wrap|Line Numbers
  1. cmbLocations.RowSource = "SELECT DL.[Location] FROM DivLoc DL WHERE DL.Division = 'V3' order by DL.Location"
Try(2):
Expand|Select|Wrap|Line Numbers
  1. cmbLocations.RowSource = "SELECT DL.[Location] FROM DivLoc DL WHERE DL.Division = '" & "V3" & "' order by DL.Location"
Try(3):
Expand|Select|Wrap|Line Numbers
  1. cmbLocations.RowSource = "SELECT DL.[Location] FROM DivLoc DL WHERE DL.Division = '" & [cmbDivisions] & "' order by DL.Location"
All this assumes your DefaultView is 'Single Form' and not 'Continuous Forms'
Sep 22 '10 #4
ncsthbell
167 100+
I have tried your above suggestion and I still do not get any results in my cmbLocation box. Here are the properties on my combo boxes:

cmbDivision (same for cmbLocation)
bound column 1
column count 1
column width 1"

I have tried deleting them and rebuilding again on my form and still have no luck.
Sep 22 '10 #5
Mariostg
332 100+
Weird.
And I am sure you did a debug.print on your query:
Expand|Select|Wrap|Line Numbers
  1. cmbLocations.RowSource = "SELECT DL.[Location] FROM DivLoc DL WHERE DL.Division = '" & cmbDivisions.value & "' order by DL.Location"
  2.  
And that is how you confirmed you don't have an empty return by executing it after...
Sep 22 '10 #6
ncsthbell
167 100+
Thanks for everyone's suggestions. I tried everything suggested and still could not get it to work. SO... I created a new form with new combo boxes and this time they work. I may have messed up an option or setting that I was not aware of. But they are working like a charm now! THANKS!!
Sep 22 '10 #7

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

Similar topics

0
by: cognoscento | last post by:
I'm currently putting together a database for my work (not an expert by any stretch, so muddling through as best as I can... you know the story...) and I could use some advice and hand-holding ...
3
by: Mike Jakes | last post by:
I hope that someone can offer a little advice on this one - I've searched the group but can't find an answer. I think that I'm doing something really stupid or missing something trivial, but see...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
1
by: MrPaulC | last post by:
Hey, I wonder if anyone can possibly help me with this problem. I'm really struggling with it. Ok, I have a form with a childform inside it which is in datasheet view, this form has two combo...
2
by: ShadowHawk | last post by:
Hi Everyone. I've been having a little touble with a form I'm working on. (I'm a MS Access hobbiest). I've set up the cascading combo boxes, which is working, (I took the code from Microsoft) on a...
2
by: SPOILED36 | last post by:
I am building a database to track attendance. I have one main form with multiple subforms. Within one of the subforms name sfrDailyAttendance, I also have cascading combo boxes (cboCategory and...
3
by: buddyr | last post by:
Hello, Yesterday I recieved help with two cascading combo boxes on an access form. I went the link http://www.fontstuff.com/access/acctut10.htm And basically used their first example. Now I...
4
klarae99
by: klarae99 | last post by:
Hello, I am working on an Access 2003 Database. The tables that pertain to this issue are tblOrg, tblState, tblCity, and tblZip. I have posted the table structure with only the pertinant fields...
1
kcdoell
by: kcdoell | last post by:
Good Morning: I have a form where I am trying to create cascading combo boxes. I have done this before but I am getting the following error that is throwing me off: Procedure declaration...
7
by: Toireasa | last post by:
Hi, Newbie Access developer here, and my first post on this forum, so I might not get everything right - thanks in advance for your help and your patience! I'm using Access 2007, in XP. I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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...
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...
0
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...

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.