+ Reply to Thread
Results 1 to 7 of 7

SQL Listbox Fill

  1. #1
    Forum Contributor
    Join Date
    04-16-2020
    Location
    Alberta, Canada
    MS-Off Ver
    365
    Posts
    216

    SQL Listbox Fill

    I have a listbox fill/filter from a few dropdowns, but I want to combine the some columns in the listbox and I'm not sure how.


    for example, with the code below I'd like to combine 'Model' and 'Service' under the same column header, called 'Desc'

    Please Login or Register  to view this content.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: SQL Listbox Fill

    You'd concatenate them in the SELECT portion - for example:

    Please Login or Register  to view this content.
    I assumed you might want a space in between the field values.
    Rory

  3. #3
    Forum Contributor
    Join Date
    04-16-2020
    Location
    Alberta, Canada
    MS-Off Ver
    365
    Posts
    216

    Re: SQL Listbox Fill

    Thanks... I was close with the syntax but not close enough.

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: SQL Listbox Fill

    FWIW, you might find it simpler to write the SQL as one string with a placeholder for the table name, then just replace it - for example:

    Please Login or Register  to view this content.
    or use an alias:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-16-2020
    Location
    Alberta, Canada
    MS-Off Ver
    365
    Posts
    216

    Re: SQL Listbox Fill

    I have tbl defined as a string and tbl = "tblComponents".

    i'd have to do tbl as tableDef? where set tbl = Tables.tblComponents ?

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: SQL Listbox Fill

    No, the variable is unnecessary in the first version, and unchanged in the second one.

  7. #7
    Forum Contributor
    Join Date
    04-16-2020
    Location
    Alberta, Canada
    MS-Off Ver
    365
    Posts
    216

    Re: SQL Listbox Fill

    ok... took a little googling, but got it. so much nicer. thanks

+ 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. Capture a cell out of range of Listbox Selection and Fill in Other Listbox
    By jdasp49 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-13-2021, 01:13 PM
  2. Fill listbox with additem
    By dark_prince69 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-05-2018, 07:55 AM
  3. [SOLVED] ListBox Fill Range
    By zplugger in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-17-2015, 11:39 AM
  4. Fill out listbox with inputbox
    By sebastienkanj in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2013, 10:27 AM
  5. Replies: 12
    Last Post: 08-28-2012, 07:09 AM
  6. Msg box to fill listbox in form?
    By danielgri14 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-27-2011, 07:56 PM
  7. To Fill a Listbox from other Listbox
    By kmlprtsngh in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-24-2010, 06:00 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