Results 1 to 3 of 3
  1. #1
    shylock is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Sep 2018
    Location
    Dayton, Ohio
    Posts
    100

    Transfer Data between list boxes

    I have a form with 2 list boxes the first box contains servicesw. I want to choose service(s) in the first box and transfer that service(s) to the second list box using an "Add" button. There ar 2 columns in each lsit box. The problem is that when I click the "Add" button the service I have chosen from the first box does NOT appear in the second box. I have attached the code for the "Add" button's On Click event. Can any one help me?

    Click image for larger version. 

Name:	Add Button.PNG 
Views:	21 
Size:	8.7 KB 
ID:	36773

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    run an append query upon dbl-clic.
    it uses the list1 as criteria....the query liike:

    INSERT INTO tPickedState ( ST, StName )
    SELECT tStates.ST, tStates.State
    FROM tStates
    WHERE (((tStates.ST)=[forms]![frmPickStates]![lstBox1]));

    then update the list2

    Code:
    sub lstbox1_dbl_click()
    docmd.openquery "qaAddFromList1"
    lst2.requery
    end sub

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    This is a common topic in Access, I am sure you will find many examples of how to do this (have a look at https://office-watch.com/2010/adding...-items-part-2/).

    I found it easiest to use a local table to hold my available options (services in your case) with a boolean field called IsSelected. When I open the form I run an update query to set all records to IsSelected =False then on double-click of the Available listbox (or click of an ADD button) I run an update to turn the IsSelected=True for that record followed by requery for the two listboxes - the first one (available) record source is SELECT * FROM tblServices WHERE IsSelected=False and the second one (selected) is SELECT * FROM tblServices WHERE IsSelected=True.

    Cheers,
    Vlad

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

Similar Threads

  1. Replies: 2
    Last Post: 05-06-2015, 05:06 AM
  2. Replies: 15
    Last Post: 11-20-2013, 04:30 PM
  3. Replies: 3
    Last Post: 02-12-2013, 11:26 AM
  4. List Box Selection transfer
    By kulle in forum Programming
    Replies: 5
    Last Post: 08-16-2011, 11:59 AM
  5. List box to populate other list boxes
    By Nathan in forum Forms
    Replies: 0
    Last Post: 03-03-2009, 07:22 PM

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