Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filters in subforms... I don't manage !

Status
Not open for further replies.

kimx

Programmer
Feb 14, 2001
13
0
0
BE
Hello all,

Though I'm programming for some years now, I'm a COMPLETE Access/VBA newbie...
I'd like to find some answers that can clear my head a bit as this is driving me mad !
I'm using Access2000 and I've been reading 2 massive books about VBA and Access Programming
and still don't manage. I keep seeing stuff about DAO and ADO and just don't know what to
use anymore. I'm at the point that I'm feeling STUPID !

In fact, I've got two questions but will post them separately. So here's the first bit:

I've got a mainform, let's call it frmCustomers with Record Source the
customers table tblCustomers (not the real names but to keep it simple (for me...) ).
This form has a subform frmsubOrders, which was based on the tblOrders table. The tblOrders table
has a field 'Current' (Yes/No) indicating which is the current order.
As I didn't want to show all orders for a customer (PK link between CustomerID (tblCustomers)
and fkCustomerID (tblOrders) ) but only those with a 'current' flag set to True, I tried
everything I could with filter on the subform. I read previous posts about how to refer to
the subform like Me!frmsubOrders.Filter = blabla or Me!frmsubOrders.Form!Filter = blabla but
just don't manage with this. Keep having error messages that say that or this method is not
used or that it doesn't find frmsubOrders etc... I've put this pieces of code in the
On Load event of the main form...

The only thing that finally worked is using as Record Source a saved query which selects
* from tblOrders where Current = True.

But I'd like to know if there's a way to do it with the filter stuff as this makes it more
dynamic and how exactly I have to refer to subforms and methods of it (and where I have to put
the code).

Sorry if you feel that this has been asked before, but I've been through all the previous posts
and have tried everything I read and.... :-( Must be me...

If somebody can help me out, thanks sooo much !

Regards

Evelyne
 
I usually just change the recordsource for the subform by using
me.subformname.recordsource = strsql'passed sql statement as I feel I have better control
however your question was on filtering
here is how to refer to a filter on a subform

DoCmd.ApplyFilter,"forms!nameoffromholdinfsubform.nameofsubform!fieldname = criteria"

good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top