Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add.item in combo box not working
I created the following code, so when the form pops up the combo box should
populate with those values, but it doesn't. When the form pops up there is nothing listed in the box. The only way I have been able to get it to populate is if a specify a cell range in the boxes properties, but not all of the properties I want are listed consecutively (and I would like to keep it that way, if possible). What am I doing wrong? Private Sub frmEnterNewConsult_Initialize() 'Fill ComboBox With cboStore .AddItem "178" .AddItem "203" End With cboStore.Value = "" Store.SetFocus End Sub Your help is greatly appreciated! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add.item in combo box not working
Hi,
If you right click your userform and view code you can get all the events for that form and you will note that the initialize event doesn't include the userform name. If you put your code in that then it will work. I tested it like this Sub test() frmEnterNewConsult.Show End Sub Private Sub UserForm_Initialize() With cboStore .AddItem "178" .AddItem "203" End With End Sub Mike "Jacy Erdelt" wrote: I created the following code, so when the form pops up the combo box should populate with those values, but it doesn't. When the form pops up there is nothing listed in the box. The only way I have been able to get it to populate is if a specify a cell range in the boxes properties, but not all of the properties I want are listed consecutively (and I would like to keep it that way, if possible). What am I doing wrong? Private Sub frmEnterNewConsult_Initialize() 'Fill ComboBox With cboStore .AddItem "178" .AddItem "203" End With cboStore.Value = "" Store.SetFocus End Sub Your help is greatly appreciated! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add.item in combo box not working
Thank you for your response. I am still a little confused. And I hope that I
can explain what I see or rather am not seeing without spreading my confusion. I may have misinterpreted your statements, so bare with me while I clarify. You wrote that the initialize event does not include the userform name, so then the code written should actually say "UserForm_Initialize()"? And the ..Show should be written under the UserForm object? Because before I had the ..Show attached to the Button on the main sheet and the form would come up when I tried to debug it or of course when I clicked the button, it just didn't populate. Now that I've changed it to the way I thought you meant it, the form doesn't come up all and I get the "Object Required" error. I feel like this should be so easy, I don't know why I don't understand. "Mike H" wrote: Hi, If you right click your userform and view code you can get all the events for that form and you will note that the initialize event doesn't include the userform name. If you put your code in that then it will work. I tested it like this Sub test() frmEnterNewConsult.Show End Sub Private Sub UserForm_Initialize() With cboStore .AddItem "178" .AddItem "203" End With End Sub Mike "Jacy Erdelt" wrote: I created the following code, so when the form pops up the combo box should populate with those values, but it doesn't. When the form pops up there is nothing listed in the box. The only way I have been able to get it to populate is if a specify a cell range in the boxes properties, but not all of the properties I want are listed consecutively (and I would like to keep it that way, if possible). What am I doing wrong? Private Sub frmEnterNewConsult_Initialize() 'Fill ComboBox With cboStore .AddItem "178" .AddItem "203" End With cboStore.Value = "" Store.SetFocus End Sub Your help is greatly appreciated! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Auto Select Next Item in Combo Box | Excel Programming | |||
combo box not showing selected item.. | Excel Programming | |||
Assign macro to each item of a drop-down list or combo box - how? | Excel Programming | |||
How to clear all item from a combo box? | Excel Programming | |||
Combo Box Item | Excel Programming |