Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Select Next Item in Combo Box ssjody[_5_] Excel Programming 2 July 25th 06 07:59 PM
combo box not showing selected item.. nycdon Excel Programming 1 August 17th 05 06:28 PM
Assign macro to each item of a drop-down list or combo box - how? jbp20717[_3_] Excel Programming 1 July 27th 05 11:17 AM
How to clear all item from a combo box? 39N95W Excel Programming 8 July 19th 04 07:31 AM
Combo Box Item alfaboost Excel Programming 7 January 10th 04 06:31 PM


All times are GMT +1. The time now is 07:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"