none
Excel, Access, and Listboxes RRS feed

  • Question

  • Hi,

         I am trying to be able to create a listbox in my application that has an excel worksheet as its source, and be able to change its contents based on search criteria.  Also, I want to be able to move items from that listbox to another by clicking arrow buttons left or right, and export it to an Access database once the desired items are in that listbox.  I also want a third listbox that can have records moved from the first or second listbox that has an option to add a comment column that will be added to that record in an additional Access database that will be exported.  I found the following code on the web to move from one listbox to another:

           

    privatevoidMoveListBoxItems(ListBoxsource, ListBoxdestination)

            {

               

    ListBox.SelectedObjectCollectionsourceItems = source.SelectedItems;

               

    foreach(varitem insourceItems)

                {

                    destination.Items.Add(item);

                }

               

    while(source.SelectedItems.Count > 0)

                {

                    source.Items.Remove(source.SelectedItems[0]);

                }

            }

           

    privatevoidfirst2second_Click(objectsender, EventArgse)

            {

                MoveListBoxItems(FirstListbox, LastListbox);

            }

           

    privatevoidsecond2first_Click(objectsender, EventArgse)

     

            {

                MoveListBoxItems(LastListbox, FirstListbox);

            }

     If this works, is there some sources somewhere I can use to figure out the rest?  I think I exporting what is listed in the listbox with its associated data to another database may not be hard, I just need to know how to do it, as well as add information for an additional column that will be in the third box.

    Thanks.

    Tuesday, April 17, 2018 4:00 PM

All replies

  • Hello smtg,

    >>I am trying to be able to create a listbox in my application that has an excel worksheet as its source, and be able to change its contents based on search criteria

    What's the application? What do you mean having an excel worksheet as source? What do you mean changing its contents based on search criteria? Could you detail it for us?

    >> Also, I want to be able to move items from that listbox to another by clicking arrow buttons left or right, and export it to an Access database once the desired items are in that listbox......

    We would suggest you post one thread for one issue. For multiple issues, please post new threads for rest issue.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 18, 2018 3:09 AM
  • I want to have the excel sheet as a database.  Each line in the listbox will list all of the fields for that record in the database.  The application is choosing from a list what tests to run, and moving them to another list if they are to be run.  I need to know how to move one record to another listbox so that I can export it to its own database (which will be in Access).  For example, let's say I had a Test A, B, and C, and in each row each test had 5 Conditions listed with it in 5 additional columns, 1, 2, 3, 4, 5.  I only want to run Test B, so I hit a button to move Test B to the second column so now only Test A and C are in the first column, and B in the second.  There is a button that will export the second column when I am done.  As far as search criteria, the list may be potentially large so I need something to narrow it by date (one of the conditions).
    Wednesday, April 18, 2018 1:41 PM
  • Hello smtg,

    What's the application? Is it a windows form? An access form? Or any other project?

    You said whole design for the your application, but I failed to figure out which step troubles you. Using Excel worksheet as database? Or moving record to another listbox? Or filtering on the listbox? 

    I would suggest you narrow down your issues to one issue since we does not support multiple issues in one thread. 

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 19, 2018 6:48 AM