+ Reply to Thread
Results 1 to 11 of 11

Add TextBox for each item checked in ListBox

  1. #1
    Registered User
    Join Date
    03-10-2015
    Location
    Cincinnati, Ohio
    MS-Off Ver
    2010
    Posts
    6

    Add TextBox for each item checked in ListBox

    Hi,

    I am not married to any solution, so I will explain what I am trying to accomplish and what I currently have (which is not much). I am creating a form for vendors to fill out. In a previous userform the vendor will input item information. The number of items is variable and will change each time a new form is created.

    In this screen I need for the vendor to be able to see and select each of the items with a checkbox. Then if an item is checked I need a textbox to appear next to it for them to input the number of the selected items needed.

    All I have currently is code to make the list appear in the listbox:
    Please Login or Register  to view this content.
    Any help would be greatly appreciated.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Add TextBox for each item checked in ListBox

    How about having 2 textboxes and a command button?

    The user selects an item from the listbox, it populates the first textbox (or it could be a label), they enter the quantity in the second textbox and when they click the command button the row with the item is updated to include the quantity.

    Or, and this would be harder to implement, when the user selects an item on the listbox a hidden textbox and command button appear alongside the listbox, they enter the quantity in the textbox and when they click the command button the row is updated in the listbox.

    That would be more like what you've asked for.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    03-10-2015
    Location
    Cincinnati, Ohio
    MS-Off Ver
    2010
    Posts
    6

    Re: Add TextBox for each item checked in ListBox

    Hi Norie,

    thanks for responding so quickly.

    I am completely open to the first idea, however will this work if they need to select multiple items (and I did not mention this previously so apologies).

    For the second option, which as you say, sounds more like what I am imagining, will I need to create a hidden textbox for each potential item in the userform object or can that be done in the code if the item is selected?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Add TextBox for each item checked in ListBox

    Not sure where muliple items would come into it as the user would still need to select individual items from the listbox to enter the quantities.

  5. #5
    Registered User
    Join Date
    03-10-2015
    Location
    Cincinnati, Ohio
    MS-Off Ver
    2010
    Posts
    6

    Re: Add TextBox for each item checked in ListBox

    I guess my real question is, would option 1 be possible for multiple items in the same userform? The vendor is going to have to perform this action a certain number of times based on a previous number they entered. For example the vendor has 10 items that need to go on 4 shelves. I would like for the vendor to see this userform 4 times wherein they would check which items will go on that shelf and then next to each checked item a textbox for them to enter the quantity.

    Since they will be seeing multiple userforms already, I would like to limit that number as much as possible for ease of use purposes.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Add TextBox for each item checked in ListBox

    I'm getting a little confused, where do the multiple userforms come into it?

    What exactly will the vendor be doing?

    Can you upload an example workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

  7. #7
    Registered User
    Join Date
    03-10-2015
    Location
    Cincinnati, Ohio
    MS-Off Ver
    2010
    Posts
    6

    Re: Add TextBox for each item checked in ListBox

    Unfortunately I can't upload anything save code due to corporate policy. However I will try to more thoroughly explain how the vendor gets to the point where I would need my initial request.

    Vendor runs macros. Userform1 appears and vendor populates textboxes with generic vendor information (name etc) that is transferred to a standard form outlined in created worksheet. After Userform1 closes Userform2 opens and collects display information. After Userform2 closes Userform3 opens and the vendor inputs number of items in display. After Userform3 closes Userform4 opens X amount of times where X is the number entered into Userform3). If certain conditions are met from Userform1 and Userform2 then Userform5 opens asking the vendor how many shelves. That is where I currently am.

    I would like Userform6 to include a listbox of all of the items entered by the vendor in Userform4. When they put a check next to the item it opens a textbox for them to input the quantity. I would like them to be able to check multiple items in Userform6 with multiple textboxes. I then need Userform6 to open X amount of times based on the response to Userform5 (i.e. once for each shelf).

    Does that help? I apologize for my limitations and any confusion, and I appreciate your taking the time to consider.

  8. #8
    Registered User
    Join Date
    03-10-2015
    Location
    Cincinnati, Ohio
    MS-Off Ver
    2010
    Posts
    6

    Re: Add TextBox for each item checked in ListBox

    I think I am getting close but textbox is not becoming visible when the item is selected from the Listbox. It works if I put it in CommandButton but not under ListBox click. Here is the code I have so far:

    Please Login or Register  to view this content.
    Any help crossing the finish line would be greatly appreciated.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Add TextBox for each item checked in ListBox

    Have you tried putting a breakpoint on the Listbox's Click event (F9) and stepping through the code to see what's actually happening?

  10. #10
    Registered User
    Join Date
    03-10-2015
    Location
    Cincinnati, Ohio
    MS-Off Ver
    2010
    Posts
    6

    Re: Add TextBox for each item checked in ListBox

    I have only been writing vba code for 5 days, so I don't know what that is or how to do it.

    But I reset my thinking and tried to set it up as checkboxes instead of a listbox with checks. I think this will work better for the latter functionality if I can get the textboxes to become visible. The problem I am seeing is that I cannot set up a Click procedure sub on the checkboxes that I am creating because those are being created in the userform_initialize sub

    Please Login or Register  to view this content.
    Everything in the Checkbox_Click sub portion of the code above does not work because it is not tied to a specific checkbox...

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Add TextBox for each item checked in ListBox

    Off the top of my head I seem to recall that the Click event of a multiselect listbox doesn't always play nice.

    Why not give the DblClick (double click) event a go?
    Please Login or Register  to view this content.
    I think that should work and double clicking is kind of a more 'positive' action.

    PS A breakpoint is a tool you can use to interrupt code execution at a specific point. You can put it anywhere (almost) in the code and when execution is interrupted you can inspect variables, begin stepping through the code with F8 etc

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Selected Listbox Item to Textbox
    By TheRobsterUK in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2014, 04:07 PM
  2. [SOLVED] Displaying item from a listbox in a textbox with next 2 columns
    By kmakjop in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-25-2014, 08:44 PM
  3. [SOLVED] Display Selected Item in Listbox in Textbox
    By puuts in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-14-2014, 04:19 PM
  4. Select listbox item then appear textbox
    By sohaila in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-01-2013, 04:41 AM
  5. Retaining focus on a textbox / listbox item pair after validation = false.
    By chatterbox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2006, 06:50 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1