I have two dropdown fields that I am trying to make mutually
exclusive.
Each dropdown field (BookMarks XY1 or XY2) has either X or Y as an
item choice.
Bookmarks XY1 and XY2 can both = X or X and Y but
Bookmarks XY1 and XY2 cannot both = Y
How would I write a Macro to ensure both Fields are not Y?
This is for an MS Word 2003 protected form.
Many thanks in advance
Deb
David Sisson - 29 Jun 2007 22:23 GMT
I believe the trick is to populate the dropdowns as the user advances
through the userform. So Comboxbox 2 is not populated until CBox 1 is
answered, then you can control the choices.
'This sub erases all the choices from CBox2 when the cursor enters
CBox1
Private Sub ComboBox1_Enter()
'Clear Box 2 for new items
Me.ComboBox2.Clear
End Sub
'This subs adds the items to CBox2 as required based on the choice
made in CBox1 after the user tabs or clicks out of CBox1.
Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Select Case ComboBox1
Case "X"
Me.ComboBox2.AddItem "X"
Me.ComboBox2.AddItem "Y"
Me.ComboBox2.AddItem "Z"
Case "Y" 'CBox is already Y, so we'll just exclude it from the
choices.
Me.ComboBox2.AddItem "X"
Me.ComboBox2.AddItem "Z"
End Select
End Sub