D
davidbui
Guest
Please can some kind person tell me how to make a feature on my form where a user is cannot enter the same value in different combo boxes.
E.g. I have 8 combo boxes called Degree 1,2,3 etc...... all linked to the same table, but i don't want a user to be able to select a value in more than one combo box.
As i couldn't solve this problem, i have tried a different method, of using a validate button to check for any repeating values. Even this doesn't work as the conditions compares null values. The code for this is below;
For txtCount1 = 0 To 7
For txtCount2 = 0 To 7
If txtCount1 <> txtCount2 Then 'If Values of two array elements are the same then next loop
If txtValues(txtCount1) = txtValues(txtCount2) Then 'If Values are the same then build then build msgbox value
textString = textString & "Error - Value in Combo_" & txtCount1 + 1 & " is the same as the Value in Combo_" & txtCount2 + 1 & ""
textString = textString & vbCrLf
End If
End If
Next txtCount2
Next txtCount1
If textString <> "" Then ' If there are errors display message
MsgBox textString
Else 'Display No Errors
MsgBox "No Errors"
End If
End Sub
If anyone out there can tell me a solution to either problem i will be very grateful.
E.g. I have 8 combo boxes called Degree 1,2,3 etc...... all linked to the same table, but i don't want a user to be able to select a value in more than one combo box.
As i couldn't solve this problem, i have tried a different method, of using a validate button to check for any repeating values. Even this doesn't work as the conditions compares null values. The code for this is below;
For txtCount1 = 0 To 7
For txtCount2 = 0 To 7
If txtCount1 <> txtCount2 Then 'If Values of two array elements are the same then next loop
If txtValues(txtCount1) = txtValues(txtCount2) Then 'If Values are the same then build then build msgbox value
textString = textString & "Error - Value in Combo_" & txtCount1 + 1 & " is the same as the Value in Combo_" & txtCount2 + 1 & ""
textString = textString & vbCrLf
End If
End If
Next txtCount2
Next txtCount1
If textString <> "" Then ' If there are errors display message
MsgBox textString
Else 'Display No Errors
MsgBox "No Errors"
End If
End Sub
If anyone out there can tell me a solution to either problem i will be very grateful.