Results 1 to 5 of 5
  1. #1
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79

    2-Dim array as list to a ListBox

    Hi,



    I have an Unbound ListBox (named lstMyList) in a Form. I want to add a 2-Dim array (named avMyLIst) as list to the listbox. In Excel I use:

    Code:
    Me.lstMyList.List = avMyLIst()
    However, I noticed that the property .List doesn't exist in Access. How can I assign a 2-Dim array as a list to an Unbound ListBox in Access? Is it possible?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you need to set the rowsource type to value list then you will need some code to parse through your array to create a semi colon separated string which will look something like

    1;option1;2;option2;3.......

  3. #3
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Doesn't I need different signs (Semi colon and something else) to separate new row & columns? If I use only semi colon, it seems that eveything will be placed in column 1. I want to have column 2, 3, ... .

  4. #4
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Got it!

    Code:
    with Me.lstStaffAssignedToJob
        .AddItem "1;2;3"
        .AddItem "4;5;6"
    end with
    That created 3 columns and 2 rows. Now I know how to proceed.

    Thanks!

    I appreciate your help.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    it seems that eveything will be placed in column 1. I want to have column 2, 3, ... .
    it looks like you have a solution, but normally you would set the column count to the required number of columns.

    Whilst we're at it:

    use the column widths property to hide or size columns as required - if you just want to hide the first column all you need to enter is 0

    the bound column is the value that will be returned when the user selects an item

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to populate list box from an array?
    By AAAndy in forum Forms
    Replies: 5
    Last Post: 08-19-2016, 08:23 AM
  2. Replies: 2
    Last Post: 01-31-2016, 08:08 PM
  3. Replies: 5
    Last Post: 08-11-2014, 03:08 PM
  4. list files recursively and store results in array
    By maxbre in forum Programming
    Replies: 2
    Last Post: 11-10-2011, 01:49 AM
  5. adding list to a listbox
    By jetrow in forum Access
    Replies: 0
    Last Post: 08-15-2006, 03:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums