473,804 Members | 3,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cascading Combo Boxes Query

1 New Member
Hi Guys,

I'm in desparate need of help. I am producing a database for my dissertation and have got majorly stuck. I am currently creating a form in which the user will select a student from a combo box, which that selection populates the next combo for the course selection. I have managed to do that with the coding shown below, my next combo will work from the course selection to bring back the feedback topics associated with that course, that there brings back one of my issues. Using the methods below i.e.queries, etc i cannot work out how to cross-reference one table to another using the results from the 2nd combo.

1st Combo Selection

Query

qryStudent

Select DISTINCT CoursesTakenbyS tudent.StudentI D
FROM CoursesTakenbyS tudent
ORDER BY CoursesTakenbyS tudent.StudentI D;

Row Source

SELECT DISTINCTROW [qryStudent].[StudentID]
FROM [qryStudent];

After Update

Private Sub cboStudent_Afte rUpdate()

Me!cboCourse = Null
Me!cboCourse.Re query

End Sub

2nd Combo Selection

Query

qryCourse

SELECT DISTINCT CoursesTakenbyS tudent.CourseCo de
FROM CoursesTakenbyS tudent
WHERE (((CoursesTaken byStudent.Stude ntID)=[Forms]![StudentFeedback]![cboStudent]))
ORDER BY CoursesTakenbyS tudent.CourseCo de;

Row Source

SELECT DISTINCTROW [qryCourse].[CourseCode]
FROM [qryCourse];

After Update

Private Sub cboCourse_After Update()

Here is the table structure i have in place:

tbl CourseTakenbySt udent
StudentID (pk)
CourseCode (pk)

These two tables are joined through a table Course via CourseCode.

tbl CourseFeedbackT opics
CourseCode (pk)
TitleID (pk)

If anyone could help it would be gratefully receieved.

Many Thanks

Didihynes
Mar 28 '08 #1
1 2521
Fiddler2
19 New Member
Hi Guys,

I'm in desparate need of help. I am producing a database for my dissertation and have got majorly stuck. I am currently creating a form in which the user will select a student from a combo box, which that selection populates the next combo for the course selection. I have managed to do that with the coding shown below, my next combo will work from the course selection to bring back the feedback topics associated with that course, that there brings back one of my issues. Using the methods below i.e.queries, etc i cannot work out how to cross-reference one table to another using the results from the 2nd combo.

1st Combo Selection

Query

qryStudent

Select DISTINCT CoursesTakenbyS tudent.StudentI D
FROM CoursesTakenbyS tudent
ORDER BY CoursesTakenbyS tudent.StudentI D;

Row Source

SELECT DISTINCTROW [qryStudent].[StudentID]
FROM [qryStudent];

After Update

Private Sub cboStudent_Afte rUpdate()

Me!cboCourse = Null
Me!cboCourse.Re query

End Sub

2nd Combo Selection

Query

qryCourse

SELECT DISTINCT CoursesTakenbyS tudent.CourseCo de
FROM CoursesTakenbyS tudent
WHERE (((CoursesTaken byStudent.Stude ntID)=[Forms]![StudentFeedback]![cboStudent]))
ORDER BY CoursesTakenbyS tudent.CourseCo de;

Row Source

SELECT DISTINCTROW [qryCourse].[CourseCode]
FROM [qryCourse];

After Update

Private Sub cboCourse_After Update()

Here is the table structure i have in place:

tbl CourseTakenbySt udent
StudentID (pk)
CourseCode (pk)

These two tables are joined through a table Course via CourseCode.

tbl CourseFeedbackT opics
CourseCode (pk)
TitleID (pk)

If anyone could help it would be gratefully receieved.

Many Thanks

Didihynes
If I'm reading this correctly (and it is for a "dissertati on", not your homework) there is a logic flaw. For one thing, if your goal is to populate a combo box with available courses for the student to take, you would not be including the ones he/she already took, but would need to eliminate those.

You would be working with 3 tables: students, courses taken, and courses available.

Your first table would have studentID (and other student data)
Your "coursestak en" middle table would have studentID and courseID (and an assignmentID, but that's optional)
Your third table would have courses available id and course name

You would need an intermediary query to build this relationship for your second combo box. It would read something like this (put in your own field names):

SELECT coursestaken.st udid, coursesavail.co urseid, coursestaken.co urseid
FROM coursesavail LEFT JOIN coursestaken ON coursesavail.co urseid = coursestaken.co urseid
WHERE (((coursestaken .studid)=[Forms]![Form2]![cboStudents]))

now that we have the qryCoursesTaken , we need to eliminate those values from the second combo box by nesting that query in another query:

SELECT coursesavail.co urseid, coursesavail.CO URSE, qryCoursesTaken .studid, qryCoursesTaken .coursestaken.c ourseid
FROM coursesavail LEFT JOIN qryCoursesTaken ON coursesavail.co urseid = qryCoursesTaken .coursesavail.c ourseid
WHERE (((qryCoursesTa ken.coursestake n.courseid) Is Null))

Save this as qryCoursesAvail

Your recordsource for the second combo box would become this:

qryCoursesAvail

This is the way I see your code after properly setting up the tables and queries:

cboStudent.rows ource = Select distinct [studentid],[studentname] from qryStudent
cboCourses.rows ource = Select [courseid],[studentid] from qryCoursesAvail
afterupdate: me.Courses.requ ery
Mar 28 '08 #2

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

Similar topics

9
6771
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 second combo to change depending on what values the user selects in the first box, it's just that every time the user changes the first combobox, the second combobox FOR EVERY RECORD goes blank.
6
2088
by: visionstate | last post by:
Hi there, I am building a database that requires cascading lists on a form. I currently have (I may be adding more later) 3 combo boxes on my form - Department, Surname and Forename. The user chooses the department they want and then the corresponding surnames from that department can be chosen from the Surname box and then the Forename depending on which Surname they chose. I then have a command button which produces the results of the...
4
64652
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...
2
2289
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 cboException) to filter difference absences (ie.Regular, Overtime, etc). cboCategory is filtered as follows: !!... Because I have the subform set up as a continuous form, I needed to add a text box (txtException) on top of one of the combo boxes...
3
3701
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 may need 3 cascading combo boxes and I cannot figure out how to do that. Can you help? Thank you
4
3502
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 below. tblOrg OrgID, AutoNumber, PK ZipID, Number, FK tblState StateID, AutoNumber, PK
1
2676
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 does not match description of event or procedure having the same name. Basically have three tables: One for the Division location:
3
3989
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment list will 'display in the drop down list of CboSegment With Me! If IsNull(Me!cboDivision) Then
7
5842
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 currently trying to set up a whole pile of cascading combo boxes of different levels of complexity, so I started with the easiest set - and can't even get that to work (even using the tutorial on this site at...
0
9705
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
9576
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
10323
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
10310
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
10074
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
9138
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
5515
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...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4291
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

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.