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 / March 2005

Tip: Looking for answers? Try searching our database.

Check if item is present in combo without trigger the change event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fms - 23 Mar 2005 17:12 GMT
I want to fill a combobox with unique items.
What is the easiest way to check if an item is already there, without
triggering the change event?

A simple way is to loop through the combo by setting the listindex from min
to max, and check if cbo.value = string, but this triggers the change event.
Cindy M  -WordMVP- - 27 Mar 2005 17:05 GMT
Hi Fms,

> I want to fill a combobox with unique items.
> What is the easiest way to check if an item is already there, without
> triggering the change event?
>  
> A simple way is to loop through the combo by setting the listindex from min
> to max, and check if cbo.value = string, but this triggers the change event.

WHY are you using the Change event? To do what?

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 :-)
fms - 29 Mar 2005 18:51 GMT
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.

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?

Fred

"Cindy M -WordMVP-" <C.Meister-C@hispeed.ch> skrev i melding
news:VA.0000aa46.00b12dba@speedy...
> Hi Fms,
>
[quoted text clipped - 16 lines]
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
Cindy M  -WordMVP- - 29 Mar 2005 21:50 GMT
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
[quoted text clipped - 6 lines]
> 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 :-)
 
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.