Populating item into combo box

L

lywong

I have a form in folder(Project Profile) that haf such a code:
Function Item_Open()
Dim objNameSpace
Dim objProjectProfileFolder
Dim objAllProfiles
Dim objFormPage
Dim objComboClient
Dim objProjectProfile

Set objNameSpace = Application.GetNameSpace("MAPI")
Set objProjectProfileFolder = objNameSpace.Folders("Invoic
Tracking").Folders("Project Profiles")

Set objAllProfiles = objProjectProfileFolder.Items

Set objFormPage = Item.GetInspector.ModifiedFormPages("Billin
Milestone")
Set objComboClient = objFormPage.Controls("cboClient")

For Each objProjectProfile in objAllProfiles
'If-else condition shld be set here
objComboClient.AddItem objProjectProfile.UserProperties("Company")
Next
End Function

How should I put inorder for the cboClient to not repeat same item?
The code now display: 'red, 'blue', 'green','red'
But i only want it to display unqiue items as: 'red, 'blue', 'green'

After the cboClient is selected, it haf to search the matching item an
load the data into cboProject.

I tried something like:
Sub cboClient_Click
'Some code here
msgbox "Here"
End Sub

But it didnt work when I click the cboClient.
Can someone pls enlighten me?

Thanks
 
K

Ken Slovak - [MVP - Outlook]

Is the cboClient control bound to a user property? If so the Click event
won't fire. You can use the CustomPropertyChange event to see when the user
property changes values. See http://support.microsoft.com/?kbid=290660 for
more information.

I usually use a trick to make sure my entries to a list are unique. I first
add each item to a collection and set the collection item and key to the
value to be added. If I get an error adding an item to the collection it
means that there is already an item in the collection that matches the new
item you are trying to add. After the collection is complete I iterate it
and add its members to the list.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top