Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2002
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Filter won't work on a subform (2000)

    The problem:

    frmSearchForm builds a filter called stLinkCriteria. A button on frmSearchForm opens frmSearchResults to display the found records.

    A button on frmSearchResults opens frmCCU that includes frmSearchResults as subform on a Tab called "SEARCH RESULTS". (I am leaving frmSearchResults open.)

    In my efforts to get the subform to apply the filter, the OnLoad event for frmCCU includes:

    dim stLinkCriteria as String
    stLinkCriteria = Forms![frmSearchResults].Filter
    Debug.Print stLinkCriteria 'stLinkCriteria is populating with the filter
    [subSearchResults].SetFocus 'try putting focus on the sub report before applying filter
    DoCmd.ApplyFilter stLinkCriteria

    If anyone can point out the error of my ways, I'd greatly appreciate it.

    Thanks,

    Randy

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filter won't work on a subform (2000)

    (1) ApplyFilter has 2 arguments: FilterName and WhereCondition. FilterName is the name of a stored filter query. If you don't want to use this, you must either place a comma before the WhereCondition or use named arguments:

    DoCmd.ApplyFilter , stLinkCriteria

    or

    DoCmd.ApplyFilter WhereCondition:=stLinkCriteria

    (2) I've had problems with ApplyFilter in Access 97 - sometimes it fails to do anything without raising an error. So I suggest setting the Filter and FilterOn properties instead:

    With [subSearchResults].Form
    .Filter = stLinkCriteria
    .FilterOn = True
    End With

  3. #3
    Star Lounger
    Join Date
    Feb 2002
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filter won't work on a subform (2000)

    Hans -

    I sure spent a lot of time going around in circles with this. I took your advice and used
    With [subSearchResults].Form
    .Filter = stLinkCriteria
    .FilterOn = True
    End With

    and it now works fine.

    Thank you very much for your help with this. Maybe now my hair can start to grow back.

    Randy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •