0
votes

Have controls on main form that control a subform on the main form. One control I have is a clear filters button, when clicked I would like it to clear subform to null

I'm setting up a user form, based on this user form the user will select what they want to see based on a few controls on the main form such as list boxes. After they select what they want the sub form below to present they will hit a filter button that navigates the sub form which is a datasheet to display this information. Whenever they want to see a new subset search I have a clear filter button that deselects all the list boxes selection to null however I am having trouble writing the code to get the sub form below to reset to null?

    Forms![dbo_tblPrintCenter subform].cmd_ClearFilters = ""

Did not work and also I've tried this

    [Print Request Search Form] = main form
    [dbo_tblPrintCenter subform] = Subform
    Forms![Print Request Search Form]![dbo_tblPrintCenter 
    subform].Form.Requery
2
You don't want any records to display on subform? Or do you want to clear the filter and show all records? Subform is not linked to main form? - June7
I just need to clear filter button to work, by work I mean to clear all records displayed on subform. Essentially there will be records down here in the subform after a user selects what they want to see in the main form. - Sebastian
Subform is not linked to mainform - Sebastian

2 Answers

0
votes

If I understand, you don't want any records to display in subform.

Set subform Filter property to criteria guaranteed to not match records, such as:

ID = 0

or

1 = 0

0
votes

If you have Filtering on your Subform then a way is :

Form_Name-Of-YourSubForm.Filter =""
Form_Name-Of-YourSubForm.FilterOn =False

To clear the textboxes

 Dim ctl as Control
For each ctl in Subform.Control
If ctl.ControlType = acTextBox then
ctl =""
End if

Next