PC Review


Reply
Thread Tools Rate Thread

Combo Box vba that works like Forms Menu combo box

 
 
Hector Fernandez
Guest
Posts: n/a
 
      12th Dec 2006
I've looked for quite some time for a solution, but can't seem to find
it.

All I want to do is make a combo box in an User Form that works just
like the combo box in the Forms toolbar.

I can get the User Form combo box to show a range of options from which
to choose from (same as the Input Range Control for the combo box in
Forms, but I can't for the life of me figure out how to get it to
simply put in a number in a linked cell (as the Forms toolbox does).

With forms, the selection you make puts a number, depending on the
combo box choice, in the Linked Cell of my choice. I want to do
exactly the same thing with the User Form combo box - HELP

 
Reply With Quote
 
 
 
 
thesquirrel@gmail.com
Guest
Posts: n/a
 
      12th Dec 2006

You can use code like this to place the value of the combo box in a
cell.

Private Sub ComboBox1_Change()
Range("A1").Value = ComboBox1.Value
End Sub

that is very basic code that will enter the value in a cell whenever
the combobox changes.

Hope that helps.

theSquirrel




On Dec 12, 11:36 am, "Hector Fernandez" <public.resea...@gmail.com>
wrote:
> I've looked for quite some time for a solution, but can't seem to find
> it.
>
> All I want to do is make a combo box in an User Form that works just
> like the combo box in the Forms toolbar.
>
> I can get the User Form combo box to show a range of options from which
> to choose from (same as the Input Range Control for the combo box in
> Forms, but I can't for the life of me figure out how to get it to
> simply put in a number in a linked cell (as the Forms toolbox does).
>
> With forms, the selection you make puts a number, depending on the
> combo box choice, in the Linked Cell of my choice. I want to do
> exactly the same thing with the User Form combo box - HELP


 
Reply With Quote
 
Hector Fernandez
Guest
Posts: n/a
 
      12th Dec 2006
Squirrel,

I've tried your recommendation, however all it does it put the actual
text from the ComboBox into the chosen linked cell.

So, if my list of options in the ComboBox is, for example:

Car
Boat
Plane

If I choose Boat I would expect it to put a value of 2 in my chosen
linked cell, however it is putting the word Boat in the cell.

What am I doing wrong?

 
Reply With Quote
 
thesquirrel@gmail.com
Guest
Posts: n/a
 
      12th Dec 2006
Nothing at all, it was my mistake, I thought you wanted the chosen
value of the combo box to be in the cell.

Change the code to the following:

Private Sub ComboBox1_Change()
Range("A1").Value = ComboBox1.ListIndex + 1
End Sub

This will place the number in the cell instead of the value.

Just for your information, the index for list boxes starts at 0 instead
of 1, thus the + 1 at the end.

theSquirrel

On Dec 12, 12:01 pm, "Hector Fernandez" <public.resea...@gmail.com>
wrote:
> Squirrel,
>
> I've tried your recommendation, however all it does it put the actual
> text from the ComboBox into the chosen linked cell.
>
> So, if my list of options in the ComboBox is, for example:
>
> Car
> Boat
> Plane
>
> If I choose Boat I would expect it to put a value of 2 in my chosen
> linked cell, however it is putting the word Boat in the cell.
>
> What am I doing wrong?


 
Reply With Quote
 
Hector Fernandez
Guest
Posts: n/a
 
      12th Dec 2006

thesquirrel,

Thank you, exactly what I wanted.

I knew it had to be something simple, I just couldn't find out what -
I'm a noob at this.

Again, thanks.

 
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
Parameter queries using forms with combo boxes, with select all, and defaulting combo boxes to blank fields nmoakeh@byte-x-byte.com Microsoft Access 12 15th Oct 2006 07:35 PM
Data Entry forms: use 1st combo box to filter next combo box? =?Utf-8?B?V2lsZEdvdXJk?= Microsoft Access Forms 1 23rd Jun 2006 07:43 PM
Working with forms, Drop down Menu VS Combo Box. Frankly Microsoft Access 5 12th May 2006 08:58 PM
combo box only works partly =?Utf-8?B?U2FuZHlS?= Microsoft Access 0 4th May 2006 05:04 PM
Basing five combo boxes on one other combo box in an Access forms =?Utf-8?B?Qm9iYmll?= Microsoft Access Forms 1 18th Feb 2006 11:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:52 PM.