Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Deselect a ListBox item
Brian Crawford 
    
4 years ago
I have a form with a single value ListBox that populates controls of the form when an item is selected, and updates the controls as the selection is changed.

If user that wants to deselect their already selected item, by clicking on it again (not a DoubleClick - I want to use that for something else), how do I clear the selection?  I know I just need to set the ListBox = Null, but I can't figure out which event to place the parts for updating the form (now on OnClick) and clearing the previous ListBox selection.
Dan Jackson  @Reply  
            
4 years ago
Can you train them to use CTRL+Click? Or add a Null entry at the top?
Kevin Robertson  @Reply  
           
4 years ago
If you clear the value of the list box in the Click event you will also be clearing the value in the DblClick event since the Click event runs first.

I would probably put a button or my preferred choice is a label. I like to format the label to look like a hyperlink. I put together an image as an example.
Kevin Robertson  @Reply  
           
4 years ago

Brian Crawford OP  @Reply  
    
4 years ago
I think I am going to try a global variable to save the value of the list box at the end of the OnClick event.  Then if the user clicks again, I check check the value of the ListBox and compare it to the prior.  If it is different, then continue on and save the current value in the global variable for the next time, but if it is the same, clear the selection.
Brian Crawford OP  @Reply  
    
4 years ago
Confirm. My guess worked.  Here are the steps

1) In the Declarations, add
    Public ListBoxPriorVal As String

2) InOnLoad add:
   ListBoxPriorVal = ""

3) In the OnClick event for the ListBox
   If ListBox = ListBoxPriorVal Then
      ListBox = ""
      ListBoxPriorValue = ""
   Else
     ListBoxPriorValue = ListBox
   End If

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 1:35:08 PM. PLT: 1s