Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2007

Tip: Looking for answers? Try searching our database.

Making two dropdown fields mutually exclusive

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Debbiedo - 29 Jun 2007 18:43 GMT
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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.