Help!

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


Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Forms RSS
Next:  How to turn off behavior that turns past "Du..  
Author Message
Steve Troxell
External


Since: Aug 03, 2007
Posts: 3



PostPosted: Fri Aug 03, 2007 4:57 pm    Post subject: Setting combobox.value always gives me "invalid property value"
Archived from groups: microsoft>public>outlook>program_forms (more info?)

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
Back to top
Sue Mosher [MVP-Outlook]
External


Since: Feb 11, 2005
Posts: 21627



PostPosted: Fri Aug 03, 2007 5:13 pm    Post subject: Re: Setting combobox.value always gives me "invalid property value" [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Setting the Text property should work fine:

objControl.Text = "two"

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

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Steve Troxell" <steve_troxell RemoveThis @REMOVEhotmail.com> wrote in message news:efhXXDh1HHA.5796@TK2MSFTNGP05.phx.gbl...
> 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
Back to top
Steve Troxell
External


Since: Aug 03, 2007
Posts: 3



PostPosted: Fri Aug 03, 2007 5:27 pm    Post subject: Re: Setting combobox.value always gives me "invalid property value" [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Sue Mosher [MVP-Outlook] wrote:
> 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
Back to top
Sue Mosher [MVP-Outlook]
External


Since: Feb 11, 2005
Posts: 21627



PostPosted: Fri Aug 03, 2007 5:44 pm    Post subject: Re: Setting combobox.value always gives me "invalid property value" [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I don't know why Value doesn't work.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Steve Troxell" <steve_troxell.TakeThisOut@REMOVEhotmail.com> wrote in message news:OrfpNUh1HHA.1100@TK2MSFTNGP06.phx.gbl...
> Sue Mosher [MVP-Outlook] wrote:
>> 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
Back to top
Steve Troxell
External


Since: Aug 03, 2007
Posts: 3



PostPosted: Sat Aug 04, 2007 6:53 pm    Post subject: Re: Setting combobox.value always gives me "invalid property value" [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Steve Troxell wrote:
> 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 to top
Sue Mosher [MVP-Outlook]
External


Since: Feb 11, 2005
Posts: 21627



PostPosted: Sat Aug 04, 2007 8:23 pm    Post subject: Re: Setting combobox.value always gives me "invalid property value" [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Good catch!

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Steve Troxell" <steve_troxell.TakeThisOut@REMOVEhotmail.com> wrote in message news:ei%23bVpu1HHA.1208@TK2MSFTNGP03.phx.gbl...
> Steve Troxell wrote:
>> 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 to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Forms All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum