Results 1 to 5 of 5
  1. #1
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142

    List Box hold the Previous selections

    Hi



    List Box that populates values from a table.

    I am doing a multi select and on clicking submit button (Command), the selected list appends to another table.

    Now my problem is when I wanted to the same operation next time, the list box holds the previously selected values.
    How to refresh the list box everytime.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Code to unselect all items:

    Code:
    Dim x As Integer
    For x = 0 To Me.listboxname.ListCount
         Me.listboxname.Selected(x) = False
    Next
    Or
    Code:
        Dim varItem As Variant
        With Me.listboxname
            If .ItemsSelected.Count <> 0 Then
                For Each varItem In .ItemsSelected
                    .Selected(varItem) = False
                Next
            End If
        End With
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    Thank you so much for replying.
    Its just that. I have two list boxes.
    1. Employee
    2. Projects
    Once the employee is selected. user can allot the projects from the project list table
    on clicking the add button, its been appended to a table.
    Problem is: after appending. the list box is not refreshing , when another employee is selected. The project list box hold the previous selection.


    Quote Originally Posted by June7 View Post
    Code to unselect all items:

    Code:
    Dim x As Integer
    For x = 0 To Me.listboxname.ListCount
         Me.listboxname.Selected(x) = False
    Next

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Edited my previous post after you read it.

    Does code work for you?

    I presume this listbox is UNBOUND.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    It Worked!!!!
    Thank you so much!!!

    Quote Originally Posted by June7 View Post
    Edited my previous post after you read it.

    Does code work for you?

    I presume this listbox is UNBOUND.

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

Similar Threads

  1. List Box selections
    By rharrisonjr in forum Access
    Replies: 3
    Last Post: 07-23-2016, 09:39 AM
  2. Replies: 4
    Last Post: 08-13-2015, 07:16 AM
  3. Copy list box selections to another list box
    By Gotham_Knight in forum Forms
    Replies: 1
    Last Post: 03-07-2013, 10:40 AM
  4. List Box Selections
    By MJeanBap in forum Forms
    Replies: 10
    Last Post: 04-05-2012, 06:26 AM
  5. Replies: 1
    Last Post: 05-25-2011, 08:37 AM

Tags for this Thread

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