Populate Appt. textbox from Contacts information

P

Pbeast

Trying to populate a text box when a user selects a
contact from a combo box in a custom appointment form.
This combo box is filled with contacts by last name

'OL 2000
Function Item_Open()

'POPULATES A COMBO BOX WITH THE CONTACTS
'IN THE PERSONAL CONTACT FOLDER

Const olFolderContacts = 10
On Error Resume Next

'GETS THE FOLDER FOR CONTACTS IN THE OUTLOOK FOLDER TREE
Set MyContacts = Application.GetNameSpace("MAPI").Folders
("Specials Beta Project").Folders("Business Contacts")

Set MyItems = MyContacts.Items
Set RestrictedContactItems = MyItems.Restrict
("[Email1Address] <> ''")

'Sort by LastName in ascending order
RestrictedContactItems.Sort "[LastName]"
For Each MyItem in RestrictedContactItems

'RETRIEVES THE FILEAS PROPERTY FROM THE
'FILLED OUT CONTACT FORM

Item.GetInspector.ModifiedFormPages ("P.2").Controls
("cmbContacts").AddItem MyItem.FileAs

'cmbContacts is the combo box being filled

Next
IsLoading = True
cmbContacts.ListIndex = 0
IsLoading = False
End Function


'WHEN THE USER SELECTS THE CONTACT FROM THE COMBO BOX
'I WANT IT TO AUTOMATICALLY FILL IN A TEXT BOX WITH THAT
'INFORMATION

Sub cmbContacts_Click() 'WHEN USER SELECTS CONTACT

'????THIS SHOULD FILL IN THE FIELDS
'IN THE APPOINTMENT FORM
'HERE IS WHERE I NEED THE HELP

End Sub
 
S

Sue Mosher [MVP]

Your Click event handler can use the MAPIFolder.Items.Find method to look up the contact that matches the value that the user chose in the combo box. Another solution is to use a two-column combo, where the hidden (and value) column is the EntryID for each contact. That allows you to use the Namespace.GetItemFromID method to return the contact directly.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 

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