Hi,
I am working on a project for creating course schedule. I am working on Access. So, let say I have created table with some courses. Now I want to use combo boxes which are bind with the table data. I have managed to do this. But my problem is for example.
If I select one course in first combo box, I want that in the second combo box that course to be disabled so that I cannot chose it. And so on for every combo box (Let say do this for six combo boxes)
I have this code. But the problem with my code is that whenever I chose something on the third combo box my data are erased from the combo box above.
Private Sub cboMonday_AfterUpdate()
Me.cboTuesday.RowSource = "SELECT CourseName FROM" & _
" tblCourses "
Me.cboWednesday.RowSource = "SELECT CourseName FROM" & _
" tblCourses "
MsgBox ("After Monday= ")
Dim i As Integer
For i = 0 To Me.cboMonday.ListCount - 1
If i <> Me.cboMonday.Value - 1 Then
Me.cboTuesday.AddItem (Me.cboMonday.ItemData(i))
End If
Next
Me.cboTuesday = Me.cboTuesday.ItemData(0)
For i = 0 To Me.cboMonday.ListCount - 1
If i <> Me.cboMonday.Value - 1 Then
Me.cboWednesday.AddItem (Me.cboMonday.ItemData(i))
End If
Next
Me.cboWednesday = Me.cboWednesday.ItemData(1)
End Sub
Private Sub cboTuesday_AfterUpdate()
Me.cboWednesday.RowSource = "SELECT CourseName FROM" & _
" tblCourses "
Dim i As Integer
MsgBox ("After Tuesday= ")
For i = 0 To Me.cboMonday.ListCount - 1
If i <> Me.cboMonday.Value - 1 And i <> Me.cboTuesday.Value - 1 Then
Me.cboWednesday.AddItem (Me.cboMonday.ItemData(i))
End If
Next
Me.cboWednesday = Me.cboWednesday.ItemData(0)
End Sub