How can I change list box's content via other list box's selected item?

R

Ruzanna

Hello,

In the subject all my question, but if it's not enough, I'll try t
explain it with more detiles.

For example I have application for University Entrants.
I have a list box with all examinations. And I need for definit
student fill application with selections from that list box, and I wan
that for definite student there will be other list box with al
selections examens from main examination list box.

How can I do it?

I'm very thankfull for any answer.
Ruzann
 
D

Douglas J. Steele

In the AfterUpdate event of the first listbox, you set the SQL for the
second listbox.

If the first listbox is named lstStudents, and the second listbox is namde
lstExaminations, you'd probably have something like:

Private Sub lstStudents_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT Examination "
strSQL = strSQL & " FROM Examinations "
strSQL = strSQL & "WHERE StudentID = " & Me!lstStudents
Me!lstExaminations.RowSourceType = "Table/Query"
Me!lstExaminations.RowSource = strSQL
End Sub

This assumes that lstStudents is set to Multiselect None (i.e.: you can only
pick a single student from the list), that StudentID is a numeric field and
that it's the Bound column of lstStudents.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top