A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Pulling in unique items in a drop down box



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 20th 06, 12:06 PM posted to microsoft.public.office.developer.outlook.forms,microsoft.public.outlook.program_forms
Richard Edwards
external usenet poster
 
Posts: 16
Default Pulling in unique items in a drop down box

The following code pulls in the company names of the people listed in our
contact list.

Obviously we have more than one person for each company, so the list shows
the company name more than once.

Is there a way of filtering and returning one entry person company?

Thank you.

Richard

-----

Function Item_Open()
Dim cmbContacts
Dim cmbView
Dim OVCtl1
Dim IsLoading
Dim RestrictedContactItems
Const olFolderContacts = 10
On Error Resume Next
Set cmbContacts =
Item.GetInspector.ModifiedFormPages("P.2").Control s("cmbContacts")
Set MyContacts =
Application.GetNameSpace("MAPI").GetDefaultFolder( olFolderContacts)
Set MyItems = MyContacts.Items
Set RestrictedContactItems = MyItems.Restrict("[Company] ''")
'Sort by Company in ascending order
RestrictedContactItems.Sort "[Company]"
For Each MyItem in RestrictedContactItems
cmbContacts.AddItem MyItem.CompanyName
Next
IsLoading = True
cmbContacts.ListIndex = 0
IsLoading = False
End Function




  #2  
Old January 20th 06, 02:33 PM posted to microsoft.public.office.developer.outlook.forms,microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Pulling in unique items in a drop down box

Add the names to a collection as you get them. Use the company name as both
the value and key for the collection item. Any dupes will error out in the
collection's Add method. Just ignore the error and proceed. At the end you
will have a collection of unique names. Iterate the collection to fill your
drop-down.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Richard Edwards" wrote in message
...
The following code pulls in the company names of the people listed in our
contact list.

Obviously we have more than one person for each company, so the list shows
the company name more than once.

Is there a way of filtering and returning one entry person company?

Thank you.

Richard

-----

Function Item_Open()
Dim cmbContacts
Dim cmbView
Dim OVCtl1
Dim IsLoading
Dim RestrictedContactItems
Const olFolderContacts = 10
On Error Resume Next
Set cmbContacts =
Item.GetInspector.ModifiedFormPages("P.2").Control s("cmbContacts")
Set MyContacts =
Application.GetNameSpace("MAPI").GetDefaultFolder( olFolderContacts)
Set MyItems = MyContacts.Items
Set RestrictedContactItems = MyItems.Restrict("[Company] ''")
'Sort by Company in ascending order
RestrictedContactItems.Sort "[Company]"
For Each MyItem in RestrictedContactItems
cmbContacts.AddItem MyItem.CompanyName
Next
IsLoading = True
cmbContacts.ListIndex = 0
IsLoading = False
End Function





 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I set a unique signature for each profile? Lou S. Outlook - Installation 1 February 21st 06 09:33 PM
Delete items from sent items box Selector007 Outlook - General Queries 1 February 13th 06 09:47 PM
How to hide Read items? I want to see only the Unread Items in my view. [email protected] Outlook - General Queries 3 February 7th 06 02:56 PM
How to display PO Box field in Business Address Box from contact Sue Mosher [MVP-Outlook] Outlook - Using Contacts 0 January 18th 06 05:01 PM
my flagged items are not popping up in the "reminder dialog box", Karla Camarata Outlook - Using Contacts 0 January 10th 06 06:57 PM


All times are GMT +1. The time now is 06:49 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.