Results 1 to 4 of 4
  1. #1
    SamL is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2021
    Location
    NJ
    Posts
    20

    Multi-Select List Box issue

    I'm fairly new to List Boxes. I almost never use them.



    I have a multi-select listbox on a data-entry form, along with many other fields to enter. Problem. When I save a record and present a new record for data entry, every other control is blank or zero, but the listbox retains its selections. 1 - why is this happening? 2 - how do I fix it?

    Thanks,
    Sam

    EDIT. I forgot to mention that the listbox is not bound to a field in the form's recordsource. What I do is initialize a string(""), and use a For Each...Next loop to concatenate the various selected values, and assign the final string to the field. The field itself is invisible on the form, and gets updated when the user clicks a checkbox, approving the final value. This part works like a charm.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Can you try this in the Current event of the form:
    Code:
    Dim varItem
    
    
    'If me.NewRecord Then 'uncomment this line and the last if you want to reset the listbox just for new records
         For Each varItem In Me.List0.ItemsSelected 'replace List0 with your listbox name
        	Me.List0.Selected(varItem) = False
         Next
    'End if
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    SamL is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2021
    Location
    NJ
    Posts
    20
    Worked like a charm!! Thanks a million!

    I put the for each...next loop in the form's Current event, where I have other things initializing as well, and I therefore didn't need the If statement either.

  4. #4
    SamL is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2021
    Location
    NJ
    Posts
    20
    Oops! I didn't realize that you had suggested that I put the loop in the Current event. Oh, well, that's where I put it anyway. Sorry.

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

Similar Threads

  1. Replies: 10
    Last Post: 10-26-2019, 12:15 PM
  2. Multi Select Listbox Issue
    By msk7777 in forum Access
    Replies: 12
    Last Post: 05-11-2015, 09:25 AM
  3. Replies: 15
    Last Post: 11-20-2013, 04:30 PM
  4. Replies: 5
    Last Post: 07-26-2012, 12:59 PM
  5. Replies: 1
    Last Post: 10-22-2010, 10:11 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