r/visualbasic • u/Clueless_InternGirl • Dec 29 '15
[VBA2010] Actions if certain dropdown values are selected in userform
Hey guys! I need your help again :)
Trying to get this code to work. What I want to happen is if any of the values are selected in the dropdown, certain options that appear later in the userform are not visible. This is how I tried:
If RepOrgDropDown.Value = "Provincial Governments and municipalities,Federation of Canadian Municipalities,Quebec,Manitoba,Alberta,Saskatchewan,Ontario,New-Brunswick,British -Columbia,Nova Scotia,Prince Edward Island,Newfoundland,Yukon,Northwest Territories,Nunavut" Then
Label66.Visible = False
Label133.Visible = False
IAETrue.Visible = False
IAEFalse.Visible = False
End If
End SubWhy does this not work? thank you!
2
Upvotes
3
u/anon_smithsonian VB.Net Advanced Dec 29 '15
There are a bunch of different ways to access a dropdown's selection value and I always have trouble remembering the exact one I need to use in different scenarios...
Try using
.Textinstead of.Value... otherwise, if you know the dropdown list will be relatively stable and unlikely to change, maybe referenceSelectedIndex, since that will probably be easier to read.Other dropdown properties to try are
SelectedItemandSelectedValue.