Setting a combo box to a certain item

  • Thread starter Thread starter dh
  • Start date Start date
D

dh

What is the syntax to setting a combo box to a certain value in the list of
items. For instance, say one of the items was "Reset", but the combo box
has say 10 items in it.
This is in VB Script, in a Custom Outlook Form
Thanks!
DH
 
If the combo box is bound to an Outlook property, you should be able to set
the property's value to that text. If it's unbound, you use the
ComboBox.ListIndex property to whatever integer represents the row that
Reset is in.
 
What does "it didn't like it" mean? What's the full code statement? How are
you instantiating cboMyList?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
I fill the list from an access database. The error message I get when I
refer to the combo box is:

Object doesn't support the property or method 'cboMyList.ListIndex'

That is what I meant by, "it doesn't like it", error from my form when I
call that particular piece of code.
Thanks!
DH
 
Sorry, I didn't get it there at first. Here you go:

Set objPage = _

Item.GetInspector.ModifiedFormPages("MATERIAL USED")

Set cboMyList = objPage.Controls("cboMyList")

This is what I think you are looking for~!

Thanks!

DH
 
cboMyList.ListIndex should certainly work, assuming that cboMyList really is
a combo or list box. Do other properties work OK? Try this:

cboMyList.Value = "Reset"

That should be easier than ListIndex, and I should have mentioned it
earlier.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Sue,
Thanks, this got me on the correct track.
I tried your suggestion, but it would generate an error and didn't work.
I then used the following, which really did what I wanted it to do and that
is, force the user to reselect a value in the combo box.
cboMyList.Value = ""
It may be because the Combo Box is unbound, not sure, but this is working
Thanks again for your assistance!
DH
 
Glad to hear you got it working!

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top