vb list boxes

databases United States
  • 19 years ago

    I am using vb code to populate two list boxes with data from a database.  One listbox is for student ID's and the other is for student grades.  How do I code the list boxes so that when I select a student ID, I get the grades for that particular student?

  • 19 years ago

    Try something like this:

    Code:
    Private Sub cboStudents_Click()
      'clear other combo
      cboGrades.Clear
      'get the records
      Set oRS = cConn.Execute ("SELECT TheGrade FROM Grades WHERE StudentName='" & cboStudents.Text & "'"
      Do While oRS.EOF = False
          cboGrades.Add oRS("TheGrade")
      Loop
      Set oRS = Nothing
    End Sub

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” - Brian Kernighan