Listbox column help

  • newbie to vba im having trouble with listboxs and populating them with the info i need in the correct format.

    So i already have 1 listbox (lstResults) which the information in it is taken from a selected item from a combobox (cboxType)

    from lstResults i click an item and them in a separate textbox i want to add an amount eg 10 then with a commandbutton add the lstResults information and textbox amount to another listbox in different columns in the same row and then be able to add more with more selections.

    ive nearly got it working but it just over writes the last entry.



  • Without seeing what you are trying to do it's very difficult to help. I don't understand what your code is doing, e.g. what is "Hinge"?

    Code
    1. lstResults.RowSource = "Hinge"

    RowSource is not the best way to load a ListBox

  • so ive had no VBA training im learning as i go along, this is a brand new sheet ive been working on.


    Ok the jist of what im trying to achieve at this point form PickForm

    I want to be able to select a type of ironmongery from the combobox which then gives me all the options in the listbox underneath when you click on an item it will bring up a picture, in the amount box i want to be able to enter the amount of this item that i need which then will transfer down to the bottom list box which will become my pick list that i will send to a sheet within excel.

    id like the bottom box to look like this

    Product Code Description Per Unit Price Supplier Amount


    As ive said im totally new to this kinda stuff so other parts of what im doing maybe wrong but it all seems to work so far.

    Files

    • cut down.xlsm

      (329.05 kB, downloaded 38 times, last: )
  • cboType


    You cannot put a source in the RowSource Property manually and set it on Initialize. I have removed the manual entry and changed the initialize event to load it using the List Property, by using CurrentREgion this will be dynamic, so you can add product types when necessary, or remove them, without changing the code.


    Why have you set the BoundColumn to 2? It's only a one column ComboBox. the BoundColumn determines which column returns the ComboBoxes Value


    ListBox1


    AddItem will add an item, i.e a new row. So your product and amount are appearing on separate rows.


    It's a matter of choice but unless there is a need to force users to use the Close Button I find it very annoying.


    You might find my DataBaseForm useful follow the link in my signature below. There's also some useful articles there and I will be adding more as I get time

  • As i have said im learning as i go along so some things are either getting missed or changed by error.

    im very greatful for the help ty

  • Everyone has to learn, my comments were only meant to be helpful.


    Post back if you aren't sure about what I have changed.

    Hi Roy,


    Only just got round to having a look at this again as im picking it up in between my normal workload.


    Again thanks for helping out with this.

    So a couple of things as what you have changed im having a bit of trouble understanding.


    The amount is now in the next column as asked but when you add another item and amount the item lists below as required but the amount just stays with the first item and just changes it.

    Also id like to get the whole line of text from above not just the first item.

  • Check this


  • Check this


    Thats works perfect thank you

  • Not without a source to pull from, the ListBox isn't connected to any data

    Ok maybe ill have to rethink the whole form then i must have the full product code, description, price and so on in the bottom list so i can then send to a sheet to print of, email etc etc i just cant get my head round why it will only pick up the product code from my pick list??

    Anyway that's why there is 6 columns i was trying to fill with all the data i need.