Results 1 to 6 of 6
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ApplyFilter method in a Report (2000)

    I'm trying to apply a filter to a the Produzioni report in the attached mdb by using
    DoCmd.ApplyFilter , "[Giorno] between #1/11/2004# and #31/12/2004#"
    in the Open event of the report and setting the FilterOn property to Yes in the report property sheet but it still returns all the records.

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

    Re: ApplyFilter method in a Report (2000)

    You must use US date format here:

    DoCmd.ApplyFilter , "[Giorno] between #11/1/2004# and #12/31/2004#"

    1/11/2004 is interpreted as January 11, 2004.

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ApplyFilter method in a Report (2000)

    Thank you Hans

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ApplyFilter method in a Report (2000)

    I'm trying substituting values drawn from text boxes on Form1 in place of the static values in DoCmd.ApplyFilter , "[Giorno] between #1/11/2004# and #31/12/2004#"
    so I use(please see attachment)
    DoCmd.ApplyFilter , "[Giorno] between #" & Format(Forms!form1!text0, "mm/dd/yyyy") & _
    "# and #" & Format(Forms!form1!Text2, "mm/dd/yyyy") & "#"
    in the report open event but I get an error message.

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

    Re: ApplyFilter method in a Report (2000)

    The Report_Open event appends the filter to itself several times. Clear the Filter property of the report, set Filter On to No, remove the code from the On Open event, and instead, open the report from a command button on the form. Here is the code to use in the On Click event of the command button:

    <code> DoCmd.OpenReport "Produzioni", acViewPreview, , _
    "[Giorno] Between #" & Format(Forms!form1!text0, "mm/dd/yyyy") & _
    "# And #" & Format(Forms!form1!Text2, "mm/dd/yyyy") & "#"</code>

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ApplyFilter method in a Report (2000)

    Another piece of magic. <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

Posting Permissions

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