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.
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.
if you have a button (filter off)
Code:sub btnFltOff_onClick() me.filterOn = false cboState = null txtName = null chkBox.value = false end sub
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?
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.
yes put it in the button code.
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.
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.
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?
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.
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.
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.
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.