Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Nov 2004
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subforms - Setting Filter Method (Access 2002)

    I have a DB that is used to enter daily activities for a department. Each subform record source is a table and is linked to the main form by EmpID. What I am looking to do, is to have each form open to display only the current week

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

    Re: Subforms - Setting Filter Method (Access 2002)

    You can set a filter for the subforms in the On Load event of the main form and in the On Load event of each of the subforms. Both work in a quick test I did.

    1) From the main form:

    Private Sub Form_Load()
    With Me.[SubForm1].Form
    .Filter = "DatePart('ww',[Activity Date])=DatePart('ww',Date())"
    .FilterOn = True
    End With
    With Me.[SubForm2].Form
    .Filter = "DatePart('ww',[Activity Date])=DatePart('ww',Date())"
    .FilterOn = True
    End With
    ...
    End Sub

    Note the use of single quotes around ww, to avoid problems with the double quotes around the filter string as a whole.

    2) From each of the subforms:

    Private Sub Form_Load()
    Me.Filter = "DatePart('ww',[Activity Date])=DatePart('ww',Date())"
    Me.FilterOn = True
    End Sub

  3. #3
    New Lounger
    Join Date
    Nov 2004
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms - Setting Filter Method (Access 2002)

    Thanks, Hans! You're the greatest!

Posting Permissions

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