Results 1 to 4 of 4
  1. #1
    BFlat is offline Novice
    Windows 2K Access 2003
    Join Date
    Mar 2012
    Posts
    20

    Report Filter


    I have a table that has two types of facilities: A and B. In my db I run multiple reports that use the facility info via a query. I just realized that there will be times that I need to run reports off the facilities seperately. In light of not having to reproduce 15 diferrent queries and subsequently reports, is there a way I can have a button on the form that I can click to limit the results a certain type?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The WhereCondition argument of the OpenReport command applies a filter to the Report and does a very good job of it.

  3. #3
    BFlat is offline Novice
    Windows 2K Access 2003
    Join Date
    Mar 2012
    Posts
    20
    So I can understand correctly....

    I have a form filter "ABC" that opens report "123" based on parameter input. The report is souced by query "XYZ". In the date field of query "XYZ" I have Between Forms!ABC!txtStart And Forms!ABC!txtEnd where txtStart and txtEnd are parameter entry fields on the "ABC" filter form.

    On the form "ABC" the code that opens report "123" has the following:

    Private Sub Sum_Click()
    DoCmd.OpenReport "Total", acViewPreview
    End Sub

    What code would I place an additional button to say where facility type is = to A? Sorry, I'm a little slow at this.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Sorry but I've been gone all day. From Help:
    expression.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)

    ...you can see that the 4th argument is a WhereCondition argument. It could be something like:

    DoCmd.OpenReport "Total", acViewPreview, , "Type = 'A'"
    ...or...
    DoCmd.OpenReport "Total", acViewPreview, , "Type = '" & YourStringVariable & "'"

    BTW, "Type is a RESERVED WORD in Access and should not be used by you as a name of an object.
    http://www.allenbrowne.com/AppIssueBadWord.html#T


Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help - trying to Filter on report
    By JulieBright in forum Reports
    Replies: 7
    Last Post: 04-20-2012, 02:35 AM
  2. Report Filter
    By SFC in forum Reports
    Replies: 4
    Last Post: 01-11-2012, 04:13 PM
  3. Filter Report
    By BorisGomel in forum Reports
    Replies: 2
    Last Post: 06-09-2011, 03:22 PM
  4. Problems with Report Filter
    By eww in forum Programming
    Replies: 1
    Last Post: 10-20-2010, 02:58 PM
  5. How to Filter Report
    By mikel in forum Reports
    Replies: 2
    Last Post: 08-28-2009, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums