Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting a Combo Box

Status
Not open for further replies.

mman74

MIS
Aug 10, 2001
36
0
0
HK
Sorry if this sounds like a "you should know that question", but I have a form with 2 combo boxes. I would like to limit the 2nd combo box depending on what I selected in the 1st.
For example, I have 3 tables. One is teacher, one is subject, and the last one is subject_taught. I now have a form to update a 'class' table. By picking the subject, I limit the teachers that can take that class (I can get the combo box to show all subjects). I know I have to create a query to query the subject_taught table, but I have completely forgotten how to do acheive the whole process.
Thanks.
 
It sounds like you need an event procedure that is triggered after you update the first combo box ("Subjects"). I'm not sure how your tables are setup or what the field names are, but I'm assuming that you have a field for teacher names and a field for subject in the table named “subject_taught”. I would use vb code similar to the following.

Private Sub cboSubjects_AfterUpdate()
With Me.cboTeachers?
.RowSource = _
"SELECT [Teachers] FROM tblSubject_Taught " & _
"WHERE [Subject] = " & Chr(34) & Me.cboSubject & Chr(34) & _
"ORDER BY [Teachers]"
.Requery
End With
End Sub

Good Luck,
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top