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 
Button to clear text box
Karen Wilfong 
    
2 years ago
I have 2 dropdown control filter fields on my form, named VAR_IDfilter and size_namefilter.  I can dropdown and select a value in the first field, then do the same in the 2nd field to bring up a single result.

This is working great, except now I am trying to make a button which will clear the value in the 2nd field (size_namefilter), and revert back to the state after the first field was selected.

I tried this:

Private Sub btnClearSize_Click()

  Me.size_nameFilter = Null
  Me.VAR_IDFilter.Requery

End Sub

But that does not work.  The code for the filters is from the Find Record Combo (members cut), so it works with a function.  Is there a simple way to step back to the results from the first filter without clicking it again?
Karen Wilfong OP  @Reply  
    
2 years ago
Right now I can physically erase the 2nd field and hit enter on my keyboard, and that does the trick.  So how can i replicate that action on the button?
Juan Rivera  @Reply  
            
2 years ago
make a button and on click
VAR_IDfilter= Null
size_namefilter= Null
docmd.requery

this will blank out both andreset the query
Karen Wilfong OP  @Reply  
    
2 years ago
But I wish for the initial button results to remain.  I don't want to completely reset the query, just the 2nd field.

For example, selecting a certain value in the VAR_IDfilter filters 20 results that are displayed in the next field "size_nameFilter".  So access shows 20 results in the navigation bar at the bottom of the form.

Then If I select one of the sizes in the 2nd filter, Access shows 1 out of 1 results in the navigation bar.

I want the button to revert it to 1 out of 20 results (as it was when I selected a value in the first filter.
Karen Wilfong OP  @Reply  
    
2 years ago
"Initial filter results", not button results. typo.
Karen Wilfong OP  @Reply  
    
2 years ago
As mentioned, right now I can physically erase the 2nd field and hit enter on my keyboard. I was trying to use some version of SendKeys {enter} which triggers the enter button after setting the value to null.

I tried this:
Me.size_nameFilter = Null
SendKeys "{Enter}"

No joy.  I'm not sure how to get access to press my enter key after making the value null  to replicate what I can do on my keyboard.
Kevin Robertson  @Reply  
          
2 years ago
Have you tried updating the filter since you already have this function?

Private Sub btnClearSize_Click()

  size_nameFilter = Null
  UpdateFilter

End Sub
Kevin Yip  @Reply  
     
2 years ago
Hi Karen, when you assign null to the combo box, the AfterUpdate event does NOT run.  It only runs if the user manually update the combo box, not if you update it with VBA code.  If AfterUpdate doesn't run, that means UpdateFilter() doesn't run, and that's why the form's filter isn't reset.  So you need to run UpdateFilter() inside the button's Click event.
Karen Wilfong OP  @Reply  
    
2 years ago
I get a syntax error with this:

Private Sub btnClearSize_Click()
    size_nameFilter = Null
    updatefilter()
End Sub
Karen Wilfong OP  @Reply  
    
2 years ago
Kevin R's solution worked. Thank you!
I most likely misinterpreted Kevin Y's answer to mean I needed UpdateFilter() to run the function again.

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 2:40:14 PM. PLT: 0s