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

Cascading Combo Boxes to Control a Subform

Hi,

For the database I am currently working on, my employer would like the
ability to use multiple combo boxes in order to filter the database.
For instance the structure of the company is based on regions, which
are managed by a number of coordinators, who oversee a large group of
associates. I would like to use a combo box so that people accessing
the database can choose a particular region and then have a second
combo box that only shows those coordinators located within that
region.

I have been able to get to this point, but am at a loss as to how to
get the resulting selection of a coordinator to limit a continuous
subform.

Any help you could provide would be appreciated.

Cameron
Nov 12 '05 #1
2 3287
In the AfterUpdate event of the Region combobox (which would be located
on your main form for this example) you can write this to filter your
subform:

Private Sub cboRegion_AfterUpdate()
Me.subform.Form.RecordSource = "Select * From tblx Where " _
Region = '"& cboRegion & "'"
Me.Requery
End Sub

This example assumes that there is no connection/relationship between
the main form and your subform. And, of course, you replace
Me.subform.Form... with the name of your actual subform --
Me.frmRegion.Form...

and replace tblx with the name of your table for the subform.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #2
Rich P <rp*****@aol.com> wrote in message news:<40***********************@news.frii.net>...
In the AfterUpdate event of the Region combobox (which would be located
on your main form for this example) you can write this to filter your
subform:

Private Sub cboRegion_AfterUpdate()
Me.subform.Form.RecordSource = "Select * From tblx Where " _
Region = '"& cboRegion & "'"
Me.Requery
End Sub

This example assumes that there is no connection/relationship between
the main form and your subform. And, of course, you replace
Me.subform.Form... with the name of your actual subform --
Me.frmRegion.Form...

and replace tblx with the name of your table for the subform.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Hi Rich, thanks for your response. Unfortunately I still have a
couple of questions, particularly because I am not experienced with
VBA, so please bear with me. Embarrassingly I am getting a compile
error which is stating Expected: End of Statement and is highlighting
regions. The code I currently have is:

Private Sub Combo0_AfterUpdate()
Me.Combo2.Requery
Me.Associate_Cascade.Form.RecordSource = "Select * From Regions Where
" _
Regions = '"& Combo0 & "'"
Me.Requery
End Sub

This brings me to my other questions. The first one is I currently
have Me.Combo2.Requery in the procedure as well, which is how I am
updating the second or coordinators combo box. Will this affect your
code in anyway? My other question is, since the filtering of the
subform is based on both regions and coordinators should the code to
filter not be associated with the Coordinators or second combo box?
If not could you explain why?

Thanks again,
Cameron
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

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...
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...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
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...
5
by: samdev | last post by:
I have created two combo boxes in a subform.... For example 1. Combo Box State 2. Combo Box City 3. When a state from the Combo Box State is selected, the City combo box updates to reflect...
1
by: bluclouds9 | last post by:
I am new to Access and have been charged with creating a database for our course alumni. I currently have a "Contacts" form and am trying to create a subform to hold the course alumni...
20
by: luciegiles | last post by:
Hi, I have used the tutorial Cascading Combo/List Boxes to filter the combo box cboCareManager dependent on the entry to cboLocalityTeam - the common code between the two tables is LocalityCode. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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:
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
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,...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.