Multiselect restrict to one if "none" selected

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a multiselect box that has a number of choices, one of which is "None"
I would like to program the box to trigger a Msgbox if "None" is selected
in addition to other choices, as they are incompatible.

One option would be to leave "none" as the default text box data, but I
don't want to do that.

I'm thinking something like:
If strselected (some parse = "None")& not "" Then
msgbox "Cannot have 'None' and other selections--must deselect one"

My current code for the box so far is:

'taking selected limits to txtLimitsfrmlbx
Private Sub lbxLimits_LostFocus()
Dim strSelected As String
Dim varSelected As Variant

For Each varSelected In Me.lbxLimits.ItemsSelected
strSelected = strSelected & _
Me.lbxLimits.Column(1, varSelected) & vbCrLf
Next varSelected
txtLimitsFrmlbx.SetFocus
txtLimitsFrmlbx.Text = strSelected
End Sub

Thank you for any ideas,
Karl
 
Hi Alex, thank you for responding. Trying the code, it brings up the MsgBox
when "None" is selected by itself, and that should be an acceptable response.
How should I change it the code?
Thank you very much,
Karl
 
Hi again,
I changed your last code to: ....ubound(split(strSelected,vbCrLf)) >1
and that took care of the glitch with "none" triggering the message box.
Thank you, again, it was very helpful,
Karl
 
Back
Top