Setting combobox.value always gives me "invalid property value"

  • Thread starter Thread starter Steve Troxell
  • Start date Start date
S

Steve Troxell

Outlook 2007

I am new to working with Outlook forms. I have tried the following with
both bound and unbound combobox controls. Every time I always get
"invalid property value" when setting the Value property on the last
line. Apparently I am misunderstanding how set the value of a combobox.
Can anyone tell me what I am doing wrong here?


objControl.ColumnCount = 2
objControl.TextColumn = 0
objControl.BoundColumn = 1
objControl.ColumnWidths = ";0"

objControl.AddItem("one")
objControl.List(0, objControl.BoundColumn) = 1

objControl.AddItem("two")
objControl.List(1, objControl.BoundColumn) = 2

objControl.AddItem("three")
objControl.List(2, objControl.BoundColumn) = 3

objControl.Value = 2 <-- error here


The idea here is to have display values separate from hidden data
values. I thought setting the Value property here would set the combobox
to show "two" as the selected value. This code is running in the
Item_Open event.



Steve Troxell
 
Setting the Text property should work fine:

objControl.Text = "two"

Is this a bound or unbound control? If bound, to what field?
 
Sue said:
Setting the Text property should work fine:

objControl.Text = "two"

Is this a bound or unbound control? If bound, to what field?

Wow. I never thought I'd get help this fast. Thank you.

The same thing happens whether it is bound or unbound. The bound
combobox is bound to numeric field. There are no items created yet for
this form. I get the error just testing it in design mode.

Setting the Text property did work. But I am left wondering why Value
didn't work the way I expected it to. It still would be preferable to
just set Value and not Text unless that's the only choice I have.

Steve Troxell
 
Steve said:
Outlook 2007

I am new to working with Outlook forms. I have tried the following with
both bound and unbound combobox controls. Every time I always get
"invalid property value" when setting the Value property on the last
line. Apparently I am misunderstanding how set the value of a combobox.
Can anyone tell me what I am doing wrong here?


objControl.ColumnCount = 2
objControl.TextColumn = 0
objControl.BoundColumn = 1
objControl.ColumnWidths = ";0"

objControl.AddItem("one")
objControl.List(0, objControl.BoundColumn) = 1

objControl.AddItem("two")
objControl.List(1, objControl.BoundColumn) = 2

objControl.AddItem("three")
objControl.List(2, objControl.BoundColumn) = 3

objControl.Value = 2 <-- error here

Found the problem: Neither TextColumn nor BoundColumn are zero-based
indexes for columns and I am treating them as such here. So when I set
the Value property to an integer value, it was trying to stick it in a
column I did not intend and found no matching values.

The working code is now:


objControl.ColumnCount = 2
objControl.TextColumn = 1
objControl.BoundColumn = 2
objControl.ColumnWidths = ";0"

objControl.AddItem("one")
objControl.List(0, objControl.BoundColumn - 1) = 1

objControl.AddItem("two")
objControl.List(1, objControl.BoundColumn - 1) = 2

objControl.AddItem("three")
objControl.List(2, objControl.BoundColumn - 1) = 3

objControl.Value = 2

Steve Troxell
 
Back
Top