Ask Experts Questions for FREE Help !
Ask
    mcleyn's Avatar
    mcleyn Posts: 48, Reputation: 1
    Junior Member
     
    #1

    Jun 4, 2009, 08:46 AM
    Mulitple Combo Box
    I have seen before in a database a certain combo box.
    I am using MS Access 2000 and Visual Basic.
    This combo box had 5 choices, all these choices had a control source to a field called Initiatves; so when a user clicked a choice it was a new record in the initiative field in the tblMain.
    The twist is that the user has the option of clicking up to 5 choices. So they can click 1, 2,. or up to 5 etc. And if they choose 5 of the options in the combo box, each 5 choices will be populated as new records in the initiatives field.
    It worked like this. The combo box was in a form. Under the label(initiatives) was the combo box, once the user clicked a choice right away a new combo box would appear under the first combo box, with a line in between separating the choices. If the user clicked a second choice with this new box that appeared and wanted a third choice all the user had to do was click under the new line that separates the choices and then another combo drop down box would appear.

    I must implement something like this into my database. I have tried a list box with mulit-select property and it allowed me to choose up to 5 options but then did not put them as new records in the appropriate field.

    How do you make a combo box like this?
    Perito's Avatar
    Perito Posts: 3,139, Reputation: 150
    Ultra Member
     
    #2

    Jun 4, 2009, 08:53 AM

    I don't think the combobox has the capability that you're suggesting. Once you're past the multi-select box, there isn't much more. However, that doesn't mean you can't create what you're trying to do.

    I think the key here is to create, on the fly, a new combobox and position it on the form over or just under the original combobox, then make it visible to the user. You have to assign a handler to it also or you'll have problems. I've done things like this. It's tricky, but possible.
    mcleyn's Avatar
    mcleyn Posts: 48, Reputation: 1
    Junior Member
     
    #3

    Jun 4, 2009, 10:13 AM
    Quote Originally Posted by Perito View Post
    I don't think the combobox has the capability that you're suggesting. Once you're past the multi-select box, there isn't much more. However, that doesn't mean you can't create what you're trying to do.

    I think the key here is to create, on the fly, a new combobox and position it on the form over or just under the original combobox, then make it visible to the user. You have to assign a handler to it also or you'll have problems. I've done things like this. It's tricky, but possible.
    Ok sounds I comprehend everything your saying up until that I have to assign a handler.
    How exactly do I do that?
    Perito's Avatar
    Perito Posts: 3,139, Reputation: 150
    Ultra Member
     
    #4

    Jun 4, 2009, 12:14 PM

    An event handler is a subroutine that the runtime calls in response to some event. In your case, you want the onclick event (combobox.click). Many people recognize event handlers that are created at compile time but when you create new controls at run time, the link to the handler needs to be made manually -- at least in .NET languages.

    Here's a link that shows how to create controls in VBA (earlier versions).

    Visual Basic Explorer - Tutorials - Create Controls At Runtime

    Add Form Controls at Run-time - Visual Basic , VB.NET

    How To Dynamically Add Controls to a Form with Visual Basic 6.0

    Visual Basic Combo Box Tutorial (VB6)

    The next-to-last link shows controls with event handlers.

    VB6 and VBA events use the names of the controls and a "_" and a suffix like "_Change"


    In .NET languages, it's similar but definitely not identical. You use this syntax to add a handler to the control.

    AddHandler Ctrl.TextChanged, AddressOf SomeSubroutine

    Here's an example:

    Create and handle controls in runtime in VB 2008

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Dvd/vcr combo [ 1 Answers ]

I need to know how to hook my magnavox dvd/vcr combo to my TV which has already installed a charter communications cable box and a magnavox sound system.

Is this d right combo? [ 2 Answers ]

First time here and not sure how this works! Will try to add as much info as possible. An HVAC installer that was referred to me by a friend gave me an estimate last Saturday on replacing my 27 y.o. furnace and 8 y.o. outside unit. This is the third estimate and least expensive. The installer...

Mulitple lights and Mulitple Switches [ 1 Answers ]

Hi, I'm in the process of finishing my basement and I want to do the wiring. I have a office room and kids play area where I want to install four lights in each room on the same circuit. I want have each room controlled by its own switch. Any help on making me understand about this wiring would...

Is there any way to do this 3-way combo? [ 2 Answers ]

G'day guys. I'm attaching a diagram of what I have. Power comes to the box at the back wall in my kitchen. From there I have one switch to control the back porch light, and a 3-way switch that controls the kitchen lights. On the other wall, adjacent to the dining room, is the other 3-way...


View more questions Search