Populate list box using "Subject" field

S

soundneedle

I have a custom appointment form that contains a textbox (txtSearch)
and listbox (lstSearchResults). I'd like the user to type in a (partial
or complete) title in txtSearch. Then have the results displayed in
lstSearchResults. Then, when the user clicks a selection in
lstSearchResults, the form navigates to that Subject, which is the
standard subject field for appointments.

Is this possible...or, maybe there's a better way to accomplish this?
Thanks for any tips...
 
S

Sue Mosher [MVP-Outlook]

Where do the results come from? And what do you mean by "the form navigates to that subject"?
 
S

soundneedle

The results is a filtered data set of the appointment [subject] field.
After the user select a result from the listbox, the form displays that
selected record. (Like bookmarks in Access, I guess).

So, appointment subject = "Doctor visit"
1.
txtSearch="Doctor"
lstSearchResults= [all appointments with "doctor" in the subject]
2. user clicks selection in lstSearchResults
3. custom forms then goes to that appointment

Now that I think about it, I'd rather simplify this and just use a
combobox that lists all appointment [subjects]. User selects value and
form navigates to the selected appointment.

This is the code I have---the only problem is, the calendar I'm trying
to retrieve data from is shared. So, I don't know how to redirect from
the "default" folder to the shared folder. The combo isn't sorting the
by subject either...Any ideas for these two issues? Thank you...


'populate search combobox
Set objFormPage = Item.GetInspector.ModifiedFormPages("Funzo")
Set objComboBox = objFormPage.Controls("cboSearch")
Set objNS = Application.GetNamespace("MAPI")

' Get the default Calendar folder
Set objCalFolder = objNS.GetDefaultFolder(9) ' olFolderCalendar

' Get the items in the folder
Set colCalItems = objConFolder.Items

' Sort the contacts based on FullName
colCalItems.Sort "[subject]"

' Loop through all of the sorted contacts
For Each objItem in colConItems
' Add the name to the listbox
objComboBox.AddItem objItem.subject
Next
 
S

Sue Mosher [MVP-Outlook]

OK, I understand, except of course there is no "go to" in Outlook. I presume you mean that you'd display the appointment.

You didn't say what you meant by a shared calendar. If it's the Calendar folder in another user's mailbox, use GetSharedDefaultFolder instead of GetDefaultFolder. If it's a folder in the Public Folders hierarchy, walk the folder hierarchy using the Folders collections or use a function that does that for you. See http://www.outlookcode.com/d/code/getfolder.htm
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



The results is a filtered data set of the appointment [subject] field.
After the user select a result from the listbox, the form displays that
selected record. (Like bookmarks in Access, I guess).

So, appointment subject = "Doctor visit"
1.
txtSearch="Doctor"
lstSearchResults= [all appointments with "doctor" in the subject]
2. user clicks selection in lstSearchResults
3. custom forms then goes to that appointment

Now that I think about it, I'd rather simplify this and just use a
combobox that lists all appointment [subjects]. User selects value and
form navigates to the selected appointment.

This is the code I have---the only problem is, the calendar I'm trying
to retrieve data from is shared. So, I don't know how to redirect from
the "default" folder to the shared folder. The combo isn't sorting the
by subject either...Any ideas for these two issues? Thank you...


'populate search combobox
Set objFormPage = Item.GetInspector.ModifiedFormPages("Funzo")
Set objComboBox = objFormPage.Controls("cboSearch")
Set objNS = Application.GetNamespace("MAPI")

' Get the default Calendar folder
Set objCalFolder = objNS.GetDefaultFolder(9) ' olFolderCalendar

' Get the items in the folder
Set colCalItems = objConFolder.Items

' Sort the contacts based on FullName
colCalItems.Sort "[subject]"

' Loop through all of the sorted contacts
For Each objItem in colConItems
' Add the name to the listbox
objComboBox.AddItem objItem.subject
Next



Where do the results come from? And what do you mean by "the form navigates to that subject"?
 

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