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

How to update a combo box depending on previous selection

6
I'm making a database for a local school, and they need a form which lets them keep track of students assignments, and in turn the grades for that assignment.

So i have a form with all the basic controls on, what I want to know is, can I auto populate a combo box depending on what a user has already selected on a previous combo box.

So for example, I have a combo box called "Course", this is just a course present in the school, Computing for example.

Under that is a combo box called "Module", this is a part of the course. First i want that to only contain modules that are present on the already selected course (Programming for Computing, for example)

AND then (:-)) is another combo box under the module called "Assignment", I want that to contain only assignments relating to the Module selected previously.

Finally, there is a student combo box, which i want to only contain the students actually on the course previously selected.
May 5 '10 #1

✓ answered by Megalog

The concept you're looking for is called Cascading combo boxes.
There's a good article here just for that: Cascading Combo/List Boxes

9 3959
Megalog
378 Expert 256MB
The concept you're looking for is called Cascading combo boxes.
There's a good article here just for that: Cascading Combo/List Boxes
May 5 '10 #2
Celor
6
Exactly what i wanted :-)

Thank's a lot
May 5 '10 #3
Celor
6
Thought i'd post here instead of starting a new topic.

I've got the first two boxes done. My module combo box updates properly depending on the course selected.

But my assignment's dont. Im using pretty much the same code from the link posted by Megalog, but I try to test it and i get...

"Syntax Error (missing operator) in query expression '[Module] = Programming Fundamentals'"

Any idea what this means?

Thanks
May 5 '10 #4
Megalog
378 Expert 256MB
Please post the after update code for the Module combo box.
May 5 '10 #5
Celor
6
The code is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Module_AfterUpdate()
  2.   With Me![Assignment]
  3.     If IsNull(Me!Module) Then
  4.       .RowSource = ""
  5.     Else
  6.       .RowSource = "SELECT [AssignmentName] " & _
  7.                    "FROM Assignment " & _
  8.                    "WHERE [Module]=" & Me!Module
  9.     End If
  10.     Call .Requery
  11.   End With
  12. End Sub
May 5 '10 #6
Megalog
378 Expert 256MB
Is the Module field in AssignmentName numeric or text? If it's text, you need to change line 8 to be:

Expand|Select|Wrap|Line Numbers
  1.                    "WHERE [Module] = '" & Me!Module & "'"
May 5 '10 #7
Celor
6
Just tried your suggestion, but they are both numeric so I got the data mistype error.
May 5 '10 #8
Celor
6
EDIT: Deleted because I've solved it. :-)

Made it search for the ModuleID and the ModuleName, bound the assignment box to column 1 (the ID) then made it only display the actual ModuleName. :-)
May 6 '10 #9
NeoPa
32,556 Expert Mod 16PB
A bit late now, but I expect Example Filtering on a Form would have helped you with this. It covers the formats of numeric, string and date literals.
May 6 '10 #10

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

Similar topics

1
by: Maria Joao | last post by:
I have two synchronized combo boxes and after the selection of the desired record, I need the user to open the related report, by pressing a button. My problem is that a combo box doesn't update...
3
by: Antoine Janssen | last post by:
hi, I would like to create two combo boxes. In the first one you can select a user in the second one you can select a project. To simplify the selection i would like to shorten the project list...
3
by: joseph.mccastlain | last post by:
Hello All, I am a new user to Access. I am currently designing a database consisting of four tables for multiple users. Rather than bore you with the goals and such, here is what I am...
2
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once...
2
daniel aristidou
by: daniel aristidou | last post by:
Hi i have used the following code to create cascade updating combo boxes. the code worked but as soon as i change the selection on the first combo the second combobox goes blank and does not refresh:...
3
by: Alo2aaa | last post by:
Dear all i have two linked combo boxes (master/child) ,the user wants to have multiple selection from both combo boxes , can u tell me how can i store them in a way that i can have a unique id...
4
by: banderson | last post by:
Hello amazing vba writers, I am trying to make a combo box return a value based on a combo box selection. I have tried a number of the codes posted here and am still having problems. I think it is...
3
by: Kernel Kev | last post by:
Hi, im doing a college assignment using Access and i seem to have hit a hard rock thats getting in my way. I will explain my task solution in hope you may be able to explain the best way to do this:...
9
by: Brett_A | last post by:
I have a form where the first field is a dynamic drop-down that pulls from a db (Access). The fields associated with the query are task_id, task_name and task_rate. The field has the value of...
10
by: truptivk | last post by:
Hello all, I have a situation and I'd appreciate it if any of you could help me. I am not sure if this is js or html but here goes. I have a main combo box (mcb) which I'm displaying some values....
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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...

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.