A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Drop-down list loses its value (Outlook 2003)



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 7th 08, 04:48 PM posted to microsoft.public.outlook.program_forms
Rod Behr
external usenet poster
 
Posts: 4
Default Drop-down list loses its value (Outlook 2003)

A drop-down box is assigned a list of values from an array:

Dim myArray(3, 1)
Set formPage = Item.GetInspector.ModifiedFormPages
Set ctrl = formPage("myForm").Controls("myControl")
myArray(0,0) = "Fred"
myArray(0,1) = 1
myArray(1,0) = "Jim"
myArray(1,1) = 2
myArray(2,0) = "Arnold"
myArray(2,1) = 3
ctrl.list = myArray

The control's list property is then set to the array. The control's bound
column is 2 (the integer value) and the number of columns is 1 to show the
string and not the integer value (primary key). The control is bound to a
user-defined field (myField).

Let's say I open the form, select "Arnold" and then close the form.

On re-opening, the drop-down control is blank (it's .list property is
correctly assigned, but it has no .value property). By unhiding the "All
Fields" form, I can see that the value of myField is 3, which is correct.

How do I go about getting the drop-down box to display "Arnold" when I
re-open the item?
  #2  
Old November 7th 08, 06:36 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Drop-down list loses its value (Outlook 2003)

Set the value property in your form's opening code from the user property.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Rod Behr" wrote in message
...
A drop-down box is assigned a list of values from an array:

Dim myArray(3, 1)
Set formPage = Item.GetInspector.ModifiedFormPages
Set ctrl = formPage("myForm").Controls("myControl")
myArray(0,0) = "Fred"
myArray(0,1) = 1
myArray(1,0) = "Jim"
myArray(1,1) = 2
myArray(2,0) = "Arnold"
myArray(2,1) = 3
ctrl.list = myArray

The control's list property is then set to the array. The control's bound
column is 2 (the integer value) and the number of columns is 1 to show the
string and not the integer value (primary key). The control is bound to a
user-defined field (myField).

Let's say I open the form, select "Arnold" and then close the form.

On re-opening, the drop-down control is blank (it's .list property is
correctly assigned, but it has no .value property). By unhiding the "All
Fields" form, I can see that the value of myField is 3, which is correct.

How do I go about getting the drop-down box to display "Arnold" when I
re-open the item?


  #3  
Old November 10th 08, 12:49 PM posted to microsoft.public.outlook.program_forms
Rod Behr
external usenet poster
 
Posts: 4
Default Drop-down list loses its value (Outlook 2003)

Ken

Thanks for the response.

My background is in VBScript (Access and ASP), so my experience of Outlook
scripting is limited. Please could you expand on what you have written. How
would I go about doing this?

Thanks

"Ken Slovak - [MVP - Outlook]" wrote:

Set the value property in your form's opening code from the user property.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Rod Behr" wrote in message
...
A drop-down box is assigned a list of values from an array:

Dim myArray(3, 1)
Set formPage = Item.GetInspector.ModifiedFormPages
Set ctrl = formPage("myForm").Controls("myControl")
myArray(0,0) = "Fred"
myArray(0,1) = 1
myArray(1,0) = "Jim"
myArray(1,1) = 2
myArray(2,0) = "Arnold"
myArray(2,1) = 3
ctrl.list = myArray

The control's list property is then set to the array. The control's bound
column is 2 (the integer value) and the number of columns is 1 to show the
string and not the integer value (primary key). The control is bound to a
user-defined field (myField).

Let's say I open the form, select "Arnold" and then close the form.

On re-opening, the drop-down control is blank (it's .list property is
correctly assigned, but it has no .value property). By unhiding the "All
Fields" form, I can see that the value of myField is 3, which is correct.

How do I go about getting the drop-down box to display "Arnold" when I
re-open the item?



  #4  
Old November 10th 08, 02:49 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Drop-down list loses its value (Outlook 2003)

Where is the code running that sets up the drop-down control? In that
procedure put in code something like this, assuming that your user property
is named "myField":

ctrl.list = myArray

Dim i 'As Integer

i = Item.UserProperties("myField")

ctrl.ListIndex = i - 1

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Rod Behr" wrote in message
...
Ken

Thanks for the response.

My background is in VBScript (Access and ASP), so my experience of Outlook
scripting is limited. Please could you expand on what you have written.
How
would I go about doing this?

Thanks


  #5  
Old November 10th 08, 03:20 PM posted to microsoft.public.outlook.program_forms
Rod Behr
external usenet poster
 
Posts: 4
Default Drop-down list loses its value (Outlook 2003)


Hi Ken

Again, thank you. You are assuming that my list of values has an incremental
primary key, which is natural from the list I gave you. The primary key is
not incremental, so the ListIndex property won't work.

So let's say my list of values is:

Fred, 13
Jim, 4
Arnold, 54

These values are assigned to an array and the array assigned to the .list
property of myControl, which is a ComboBox. This all in the Item_Open()
function of the form.

When I use the form to enter an outlook item (it's a celendar item), the
ComboBox's .list property populates fine. I select Jim and myField's value is
correctly set to 4. I close the item.

When I open it again, myControl has no value. I use MsgBox to display the
value and get an error because the value is null. Another control
(myControl2), just a Text Box, not a ComboBox, correctly displays the value
of myField as 4, but try as I might I cannot assign the value 4 to the
ComboBox.

When I attempt to set myControl's value as follows:

myControl.value = 4

I get the error, "Could not set the Value property. Invalid property value."

Why?

Thanks again for the help!

"Ken Slovak - [MVP - Outlook]" wrote:

Where is the code running that sets up the drop-down control? In that
procedure put in code something like this, assuming that your user property
is named "myField":

ctrl.list = myArray

Dim i 'As Integer

i = Item.UserProperties("myField")

ctrl.ListIndex = i - 1

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Rod Behr" wrote in message
...
Ken

Thanks for the response.

My background is in VBScript (Access and ASP), so my experience of Outlook
scripting is limited. Please could you expand on what you have written.
How
would I go about doing this?

Thanks



  #6  
Old November 10th 08, 03:42 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Drop-down list loses its value (Outlook 2003)

You have to set the ListIndex property as I indicated. If the list is not
sequential then you must get the index that corresponds to the value in the
UserProperty and supply that to the ListIndex property. If you are adding
items to the list then the first item you add is index 0 and so on. You
would have to compare each item as you add it to match it to your user value
and then get your current index value to supply to the ListIndex property.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Rod Behr" wrote in message
...

Hi Ken

Again, thank you. You are assuming that my list of values has an
incremental
primary key, which is natural from the list I gave you. The primary key is
not incremental, so the ListIndex property won't work.

So let's say my list of values is:

Fred, 13
Jim, 4
Arnold, 54

These values are assigned to an array and the array assigned to the .list
property of myControl, which is a ComboBox. This all in the Item_Open()
function of the form.

When I use the form to enter an outlook item (it's a celendar item), the
ComboBox's .list property populates fine. I select Jim and myField's value
is
correctly set to 4. I close the item.

When I open it again, myControl has no value. I use MsgBox to display the
value and get an error because the value is null. Another control
(myControl2), just a Text Box, not a ComboBox, correctly displays the
value
of myField as 4, but try as I might I cannot assign the value 4 to the
ComboBox.

When I attempt to set myControl's value as follows:

myControl.value = 4

I get the error, "Could not set the Value property. Invalid property
value."

Why?

Thanks again for the help!


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2003: Is there any way of making the contacts list of asecondary mailbox appear in the address book drop down list? QH Outlook - Installation 1 May 16th 08 11:14 AM
Outlook 2003: Is there any way of making the contacts list of asecondary mailbox appear in the address book drop down list? QH Outlook - Using Contacts 1 May 16th 08 11:14 AM
Outlook 2003 - does not show default printer in drop-down list Bill Glidden Outlook - General Queries 2 December 9th 07 11:53 AM
Outlook 2003 crash after drop down list selection with mouse Fabrício Souza Outlook - Installation 0 May 21st 07 08:10 PM
OUTLOOK 2003 CRASH AFTER DROP DOWN LIST SELECTION Ygaud Outlook - General Queries 3 March 15th 06 08:06 PM


All times are GMT +1. The time now is 10:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.