PC Review


Reply
Thread Tools Rate Thread

Add.item in combo box not working

 
 
Jacy Erdelt
Guest
Posts: n/a
 
      21st Mar 2009
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 With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      21st Mar 2009
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 With Quote
 
Jacy Erdelt
Guest
Posts: n/a
 
      23rd Mar 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box, select item, auto create another combo box in field Christine Microsoft Excel Programming 2 8th Oct 2009 07:40 PM
remove an item from a combo after using that item dennis Microsoft Access 11 5th Aug 2008 07:10 AM
combo box that once item is selected, a new combo box appears Andrew Hollis Microsoft Access Getting Started 4 7th Feb 2008 07:08 PM
Highlighting the selected item in a combo box by making the item displayed in Bold characters. doyapore Microsoft Access 1 19th Jan 2005 02:49 PM
Combo Box Item alfaboost Microsoft Excel Programming 6 10th Jan 2004 06:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:51 PM.