Results 1 to 12 of 12
  1. #1
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352

    Clear Filters and Checks on Load--Form

    When I load a form I would like the filter to clear and any selected checkboxes to be null. Essentially load the form in a 'clean' format.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    if you have a button (filter off)

    Code:
    sub btnFltOff_onClick()
       me.filterOn = false
       cboState = null
       txtName = null
       chkBox.value = false
    end sub

  3. #3
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    I should put this behind my button for clearing the filter?

    Or is there some code I can put in the forms on load event?

  4. #4
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Private Sub fltrbttn_Click()
    Me.Filter = "NeedPart =" & Me.chkNeedPart
    Me.FilterOn = Me.chkNeedPart
    End Sub


    Private Sub FltrOff_Click()
    Me.FilterOn = False
    Me.chkNeedPart.Value = Null
    End Sub


    Private Sub Form_Load()
    Me.FilterOn = False
    Me.chkNeedPart.Value = Null
    End Sub

    That is what I currently have behind my form, and I am not getting desirable results. If I select a few things via checkboxes and close and re open my form the things I selected are still selected. I want nothing to be selected when I open the form- and also when I click my FltrOff button. The filter off button and form load sequence only nullify the checkbox value of the one I had just previously clicks (so it was still highlighted). I need allll the checkboxes to clear.

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    yes put it in the button code.

  6. #6
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    I did that, and tried it in my form load event too but both are not working. They only nullify the last box I checked since it is still highlihgted if I don't click off it.

  7. #7
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I think that to set a check box to null, you have to set the triple state property to yes (or allowed/true/whatever). Otherwise, set it to no/false.
    Also, are they bound to a table/query whose values are True/Yes? If so, you will have to run an update that changes the value to No/false.

  8. #8
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Thanks for the reply! thought the thread was dead. They are indeed bound to a query whose values are yes/no, and I do have an update query for resetting those values. Do you think the easiest way to reset the values each time is to have the query run when the form is closed?

  9. #9
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Why you would bind a form to a query that returns a value only to want to change it across all of the records every time you close the form is curious for sure and sounds like bad practice. Without knowing the reason for it, I'd say yes, the easiest thing to do is run an update, but you may have to do it on the form unload event, not the close. If there is something you need on the form as criteria for the query, it may be gone when you execute since the unload unloads the form records before the close event.

  10. #10
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    The form is for users to order parts for a chemical mix department. The query attached to each specific form returns the parts and their information for specific suppliers. The checkbox in the form I have is a field to check whether they need the part or not. They then filter the form based on what they have checked, fill out some information on payments, then run a final report to send to someone to place the order. And currently the report sorts based on what was checked in the form which ties back to the query. Perhaps this is an inefficient method..but it is what I know how to do.

  11. #11
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I still am missing the part of why the form opens with the boxes checked, but I guess it doesn't matter. If running an update query to set the value to no does not help, let us know.

  12. #12
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Ohh, no no. I was trying to get it to open the form with them all un-checked. As if to "reset" the form. But the update query works just fine, thank you.

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

Similar Threads

  1. Clear text box on form load
    By RoyLittle0 in forum Access
    Replies: 3
    Last Post: 03-05-2013, 05:40 AM
  2. Filters in one form affecting another...
    By Dominaz in forum Access
    Replies: 1
    Last Post: 10-25-2011, 04:55 PM
  3. Disable Ability to Clear Filters
    By mbake085 in forum Programming
    Replies: 1
    Last Post: 06-22-2011, 09:06 AM
  4. Form Filters Help
    By JeffG3209 in forum Forms
    Replies: 1
    Last Post: 05-22-2011, 10:31 PM
  5. Creating Filters on a Form
    By Nixx1401 in forum Access
    Replies: 4
    Last Post: 02-27-2010, 05:32 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