get SQL record set into Listbox with each field on next line

  • Hi all,


    I use a excel userform to pass data to Teradata database and then get the resulst into a listbox.
    So far I managed some data getting into the listbox, but when a field is empty, code stops. If I comment those fields out in the code, then it will run as the other fields have date in them.
    As it is a listbox, I can get the data only in columns.
    This is the code I have so far:



    What can I change to make it put eache address line in one row? and how to catch if one of the address line is empty?
    And it would be great to be able to copy it from the listbox.


    Greetings.

  • Re: get SQL record set into Listbox with each field on next line


    To populate the listbox, you can replace this:


    with this:

    Code
    Me.client_details.Column = rec1.GetRows

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: get SQL record set into Listbox with each field on next line


    Hi Rory,


    That works really nice :)
    the problem I have with this still, is that the column width. If there is more text I can't auto adjust it. to fit all.
    If I can put each field data in a new row, that would do the trick. I also would need to copy the text from the list box as now I cant.


    Greetings.

  • Re: get SQL record set into Listbox with each field on next line


    Sorry, I don't follow that at all. What is the issue with column widths?


    You can easily transfer data from the listbox to other controls or cells, using its List property.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: get SQL record set into Listbox with each field on next line


    Hi,
    the problem is that when the text is longer than the column, it is not visible.
    Appart from that, I guess having each field from the query comming in a new line, would be better.


    Greetings.

  • Re: get SQL record set into Listbox with each field on next line


    hi,


    It would be good to know if the recordset can be splitted so it can come into the listbox line by line instead of thew whole recordset in one row.
    I simply would like to get each field from the recordset in a new line.


    Greetings.

  • Re: get SQL record set into Listbox with each field on next line


    How will that help? If it's too wide for the first column you will have the same problem. I think you'd be better off sticking with the listbox as it is and using some textboxes/labels to display the various parts for the selected record.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!