Hi David,
Sorry for the mistaken post above.
My task is getting closer to being solved, but I still have two issues. I have a table that displays 10 different selections for nurses shifts to choose from when any of my combo boxes are clicked, my table looks as follows:
Nurse_Id Description
1 1RN(15-19)
2 1RN(19-23)
3 1RN(15-23)
4 1RN(19-7)
5 1RN(23-7)
6 1LPN(15-19)
7 1LPN(19-23)
8 1LPN(15-23)
9 1LPN(19-7)
10 1LPN(23-7)
When I run it I can only select the corresponding description for Nurse_id 1 in the first combo box, I can't select anything with the second combobox without getting the messagebox and I can only select the 3rd Nurse_id with the 3rd combo box and so on down to the 10th.
The user may only have to make one selection and just from the first combo box and this can be any of the 10 possible Nurse_Id's.
Here is the code so far:
Public Function TestDups(cbo As Integer, Contents As String) As Boolean
Dim ChkStr As String
'This adds all the entries in each of the combo boxes into one long string EXCLUDING the combo box that is calling the function
Select Case cbo
Case 1
ChkStr = Nz(Me.cboStaffing2, "") & Nz(Me.cboStaffing3, "") & Nz(Me.cboStaffing4, "") & Nz(Me.cboStaffing5, "") & Nz(Me.cboStaffing6, "") & Nz(Me.cboStaffing7, "") & Nz(Me.cboStaffing8, "") & Nz(Me.cboStaffing9, "") & Nz(Me.cboStaffing10, "")
Case 2
ChkStr = Nz(Me.cboStaffing, "") & Nz(Me.cboStaffing3, "") & Nz(Me.cboStaffing4, "") & Nz(Me.cboStaffing5, "") & Nz(Me.cboStaffing6, "") & Nz(Me.cboStaffing7, "") & Nz(Me.cboStaffing8, "") & Nz(Me.cboStaffing9, "") & Nz(Me.cboStaffing10, "")
Case 3
ChkStr = Nz(Me.cboStaffing, "") & Nz(Me.cboStaffing2, "") & Nz(Me.cboStaffing4, "") & Nz(Me.cboStaffing5, "") & Nz(Me.cboStaffing6, "") & Nz(Me.cboStaffing7, "") & Nz(Me.cboStaffing8, "") & Nz(Me.cboStaffing9, "") & Nz(Me.cboStaffing10, "")
Case 4
ChkStr = Nz(Me.cboStaffing, "") & Nz(Me.cboStaffing2, "") & Nz(Me.cboStaffing3, "") & Nz(Me.cboStaffing5, "") & Nz(Me.cboStaffing6, "") & Nz(Me.cboStaffing7, "") & Nz(Me.cboStaffing8, "") & Nz(Me.cboStaffing9, "") & Nz(Me.cboStaffing10, "")
Case 5
ChkStr = Nz(Me.cboStaffing, "") & Nz(Me.cboStaffing2, "") & Nz(Me.cboStaffing3, "") & Nz(Me.cboStaffing4, "") & Nz(Me.cboStaffing6, "") & Nz(Me.cboStaffing7, "") & Nz(Me.cboStaffing8, "") & Nz(Me.cboStaffing9, "") & Nz(Me.cboStaffing10, "")
Case 6
ChkStr = Nz(Me.cboStaffing, "") & Nz(Me.cboStaffing2, "") & Nz(Me.cboStaffing3, "") & Nz(Me.cboStaffing4, "") & Nz(Me.cboStaffing5, "") & Nz(Me.cboStaffing7, "") & Nz(Me.cboStaffing8, "") & Nz(Me.cboStaffing9, "") & Nz(Me.cboStaffing10, "")
Case 7
ChkStr = Nz(Me.cboStaffing, "") & Nz(Me.cboStaffing2, "") & Nz(Me.cboStaffing3, "") & Nz(Me.cboStaffing4, "") & Nz(Me.cboStaffing5, "") & Nz(Me.cboStaffing6, "") & Nz(Me.cboStaffing8, "") & Nz(Me.cboStaffing9, "") & Nz(Me.cboStaffing10, "")
Case 8
ChkStr = Nz(Me.cboStaffing, "") & Nz(Me.cboStaffing2, "") & Nz(Me.cboStaffing3, "") & Nz(Me.cboStaffing4, "") & Nz(Me.cboStaffing5, "") & Nz(Me.cboStaffing6, "") & Nz(Me.cboStaffing7, "") & Nz(Me.cboStaffing9, "") & Nz(Me.cboStaffing10, "")
Case 9
ChkStr = Nz(Me.cboStaffing, "") & Nz(Me.cboStaffing2, "") & Nz(Me.cboStaffing3, "") & Nz(Me.cboStaffing4, "") & Nz(Me.cboStaffing5, "") & Nz(Me.cboStaffing6, "") & Nz(Me.cboStaffing7, "") & Nz(Me.cboStaffing8, "") & Nz(Me.cboStaffing10, "")
Case 10
ChkStr = Nz(Me.cboStaffing, "") & Nz(Me.cboStaffing2, "") & Nz(Me.cboStaffing3, "") & Nz(Me.cboStaffing4, "") & Nz(Me.cboStaffing5, "") & Nz(Me.cboStaffing6, "") & Nz(Me.cboStaffing7, "") & Nz(Me.cboStaffing8, "") & Nz(Me.cboStaffing9, "")
End Select
'Next check to see if it has aready been selected
If InStr(ChkStr, Contents) > 0 Then
TestDups = True
Else
TestDups = False
End If
End Function
Private Sub cboStaffing_Click()
If TestDups(cboStaffing, Me.ActiveControl) = True Then
MsgBox ("You have already made this selections in another combo box")
Me.ActiveControl = ""
End If
End Sub
Private Sub cboStaffing2_Click()
If TestDups(cboStaffing, Me.ActiveControl) = True Then
MsgBox ("You have already made this selection in another combo box")
Me.ActiveControl = ""
End If
End Sub
Private Sub cboStaffing3_Click()
If TestDups(cboStaffing3, Me.ActiveControl) = True Then
MsgBox ("You have already made this selection in another combo box")
Me.ActiveControl = ""
End If
End Sub
Private Sub cboStaffing4_Click()
If TestDups(cboStaffing4, Me.ActiveControl) = True Then
MsgBox ("You have already made this selection in another combo box")
Me.ActiveControl = ""
End If
End Sub
Private Sub cboStaffing5_Click()
If TestDups(cboStaffing5, Me.ActiveControl) = True Then
MsgBox ("You have already made this selection in another combo box")
Me.ActiveControl = ""
End If
End Sub
Private Sub cboStaffing6_Click()
If TestDups(cboStaffing6, Me.ActiveControl) = True Then
MsgBox ("You have already made this selection in another combo box")
Me.ActiveControl = ""
End If
End Sub
Private Sub cboStaffing7_Click()
If TestDups(cboStaffing7, Me.ActiveControl) = True Then
MsgBox ("You have already made this selection in another combo box")
Me.ActiveControl = ""
End If
End Sub
Private Sub cboStaffing8_Click()
If TestDups(cboStaffing8, Me.ActiveControl) = True Then
MsgBox ("You have already made this selection in another combo box")
Me.ActiveControl = ""
End If
End Sub
Private Sub cboStaffing9_Click()
If TestDups(cboStaffing9, Me.ActiveControl) = True Then
MsgBox ("You have already made this selection in another combo box")
Me.ActiveControl = ""
End If
End Sub
Private Sub cboStaffing10_Click()
If TestDups(cboStaffing10, Me.ActiveControl) = True Then
MsgBox ("You have already made this selection in another combo box")
Me.ActiveControl = ""
End If
End Sub
Thanks David