Question : Filtering data in a subform.

I have a search criteria form.  Users enter text for keyword search, and they can (ok, are supposed to be able to) further filter the data by clicking a series of checkboxes (Which all compare data in the same field).
The resulting form is an unbound Main form (it has buttons that do stuff), with a subform that actually presents a datasheet of the results.
I CAN NOT get the underlying query (or query plus filter query) to give me the FILTERED search results. I've tried in code and i've tried creating a query that acts as the filter.  Data won't filter.  I still only get the result set that is the results of the keyword search (I can't tell if the filter is getting ignored or if somehow it's doing an "OR" so that all of the data from both searches is returned.) Let me know if you need any additional information to solve the problem.  And feel free to ask me what i've already tried (she said while banging her head on the keyboard)...

Answer : Filtering data in a subform.

oops, you're right. since the subform is the filtered one, not the directly opened main form, we need a workaround:

frmResults is the main, unbound form
frmResultsSub is the sub-form, bound to table1

change the DoCmd to:
DoCmd.OpenForm "frmResults", , , , , , strFilter

so now the filter string is passed to the main form (frmResults) as OpenArgs.

then use the sub-form's Open event (which will fire right after the main form opens) to:

Me.Filter=Forms!frmResults.OpenArgs
Me.FilterOn=True

this should do the trick
Random Solutions  
 
programming4us programming4us