Hi Fms,
I have to combo's: cbo1 and cbo2. Changes in cbo1 shall change cbo2's
rowsource.
This works fine, except when I want to check if an item is a valid member of
cbo1's list.
Since you mention rowsource, I'm guessing you're working in Excel? (Word can't
support rowsource, and this IS a Word.vba group
) You'll be better off
asking questions in the application-specific group...
The most "obvious" answer that comes to my mind is to either store the list of
items in the one combo box in an array, and compare the array. Or store the
list in a hidden area of the workbook, and compare that.
The other approach would be to simply not use the Change event, but execute
code on exiting the field.
HOWEVER, when I loop through a combobox's list the Change event does not
trigger. So I do wonder how you're doing that. I use:
For i = 0 To ComboBox1.ListCount - 1
Debug.Print ComboBox1.List(i)
Next
If I set combo1.style = fmStyleDropDownCOMBO, I can use:
cbo1.text = item_to_check
if cbo1.listindex = -1 then <item_to_check not present cbo1>
However, if combo1.style = fmStyleDropDownLIST (as in this case) the only
way to find out if item_to_check is present in cbo1 is to check every item
in cbo1. I think. And this triggers the change event, and cbo2's rowsource
changes n times.
Is there a way to disable the change event from triggering? Or another way
to find out if item_to_check is present in cbo1's list?
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail