I need to figure out how to add the combobox values to the next empty textbox when the command button is clicked. I tried loop and if statements based on a tag assigned to the 40 textboxes but it adds the student name to all 40 textboxes. If I select a different student and click the command button it overwrites all 40 with the new name.
Is there a way to keep the students assigned to the class in textboxes, loop through them to find the next empty box and fill it (and only it) with the new name. See code below. Note I am recording the first and last names of the students that appear in column 3 & 2 of the query for the combobox.
Expand|Select|Wrap|Line Numbers
- Private Sub Command_AddStudent_Click()
- Dim ctl As Control
- Dim addstudent As String
- Dim student As String
- addstudent = Me.Cbo_StudentList.Column(3) & " " & Me.Cbo_StudentList.Column(2)
- For Each ctl In Me.Controls
- If ctl.tag = "SeatsAvailable" Then
- If ctl.Value = Not Null Then
- ctl.Value = student
- Else
- ctl.Value = addstudent
- End If
- End If
- Next ctl
- End Sub