Re: set access filter

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Brad (Brad_at_discussions.microsoft.com)
Date: 01/02/05


Date: Sun, 2 Jan 2005 10:17:03 -0800

NICE! Thanks - but I'm only halfway there. The form opens with the project
list filtered to the first client. When I click on a different client the
hidden field updates properly but the project list does not - it stays
filtered to the projects for the first client. How do I get the project list
to refresh? I tried this but it doesn't work:

    Me.Parent!ActiveProjectLst.Refresh

In case it helps, here's my code to get teh clientID out of the first list:
Private Sub Form_Current()
    Me.Parent!ClientIDLbl.Caption = Me.ClientID
End Sub

and on the project subform I set
    LInk Child Fieds = ClientID
    Link Master Fields = ClientIDLbl.Caption

thanks in advance.....

brad

"Rob Oldfield" wrote:

> Hmmm. I think I see what it is that you're trying to do. Using filters is
> not the way to go. Instead you're going to be better off using Master/Child
> fields to control which records display on the subform. (If you haven't
> played with this technique then I'd suggest using the Form Wizard to create
> a form/subform (to display clients and projects for example) so that you get
> the idea of how it works at a basic level.
>
> To use the same idea in your situation, you're going to need a textbox
> (could be anything really, but a textbox is simplest) on the main form. For
> here, I'll call it txtCli. This can be hidden in the production version.
>
> When you click a different client on the clients subform, you need to
> transfer the key field info back to the main form. That would be something
> like...
>
> parent.txtCli=me.clientID
>
> ....in the current event of the client subform.
>
> You can then filter the projects subform by settings its master field to
> txtCli (OK, it's not really a field, but it works) and its child field to
> ClientID.
>
>
> "Brad" <Brad@discussions.microsoft.com> wrote in message
> news:ADD80124-ABFE-4C7D-9A98-9A808A10D55B@microsoft.com...
> > I'm a .NET programmer trying to throw together a quick Access app but
> can't
> > figure out the object reference methods. I've got a main form with two
> > subforms, each in data *** view. Data*** 1 has a client list,
> data***
> > 2 has a project list (multiple prj per client) and the main form has
> detail
> > project info. I want to click on a client and have the prj data***
> filter
> > to only those project for that client. Then click on a project and view
> the
> > prj detail on the main form for editing.
> >
> > In the Form_Current event of the Client subform, I'm trying this:
> >
> > Forms![MainFrm]![ActiveProjectLst].SourceObject.filter = "select name from
> > ActiveProjectsQry where ClientID = '" & ActiveClientLst.ClientID & "' "
> >
> > where MainFrm is the top level form
> > ActiveProjectLst is the subform container for data*** 2
> > ActiveClientLst is the subform container for data*** 1
> >
> > My first question is: is this the proper approach? Second: How do I refer
> > to the filter property of a datasource on a subform????? Also, How do I
> get
> > the current ID value out of one subform and use it in the filter for
> another
> > subform?
> >
> > Pls help - I bid 8 hours on this "simple" app and am already 5 hours into
> it
> > with no end in sight.
> >
> >
> >
>
>
>


Quantcast