Results 1 to 6 of 6
  1. #1
    irish634 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    48

    Open a report based on a filtered list box

    Background: I am working on a database for a club membership. I have a main member table which holds contact info, etc., I have a linked table (one to many) which holds dues payments over the years.

    I have a report based on a query that yields my desired results of the last paid year for each member in the database. With no filtering, the report opens and shows every member and the last year they paid.



    I have a form with a list box. I filter and requery the list box row source with a combo box. This lists either 'all members' or only those members paid for a certain year.

    I would like to show the report based on all members in the list box. I basically want to show only the members that are in the list box, in the report.

    I know how to open based on a single selection or multi select, but for the life of me, I can't seem to make this work to open the report based on the contents of the list box.

    Any ideas?

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The list box row source is a query - you can use that query for your report.

    Or use the combo box on the form to create your report query in the same manner that you create your list box row source.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,946
    You are using combobox to select specific members that you want to report? If not, what is the combobox selecting?

    Why not a criteria that is along the lines of 'show only members who haven't paid this year'

    DoCmd.OpenReport "report name", , , "fieldname=" & criteria

    Really need to know more about data structure and report RecordSource.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    irish634 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    48
    The combo box selects: "ALL" or a particular year. The combo box list would look similar to this:

    • All
    • 2012
    • 2011
    • 2010

    If I select "all", then every member is shown, with the last paid year similar to this:

    • Member1, 2011
    • Member2, 2012
    • Member3, 2012

    When I select a given year, only those members paid for a given year show up.


    The report is basically a copy of the members shown in the list box, with a little more detail.


    I think the criteria solution is giving me fits because of the way my tables and relationships are. The member table is where "Member1" is stored, but the paid year is stored in the sub table and the query can show the same member with multiple years.
    So my query would wind up like this:

    • Member1, 2011
    • Member2, 2012
    • Member2, 2011
    • Member3, 2012
    • Member3, 2011

    Both answers pointed me in the right direction, Aytee's response made a light bulb go on for me and for the time being I am changing the underlying query with the QueryDef property and it works fine. It's been one of those days where you think so hard you overlook some easy things....



    But the "tinkerer" in me needs to figure out the "criteria" method with the way I have my tables set up.



    Thanks!

    Craig

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,946
    So when you select 'All' you really mean 'all members and their last year paid'?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    irish634 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    48
    Quote Originally Posted by June7 View Post
    So when you select 'All' you really mean 'all members and their last year paid'?
    Yes. That is correct.

    My data structure is here:
    Attachment 6167

    My underlying query for 'ALL Members' returns the MAX of the lng_MembershipYear field. This avoids me getting a list of every member along with every year they paid.

    When I want to show the report for a certain year only, the above query does not work if I choose to see 2011 when there is also an entry for 2012 (since I am returning the max).

    I'll try to upload a sample DB a little later today. I know that's usually easier to see the method to someone's madness. Either way, I have it working by changing the query def, but I'm still interested in figuring this out.

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

Similar Threads

  1. Report based of filtered data from a form
    By Fabdav in forum Reports
    Replies: 1
    Last Post: 09-15-2011, 05:28 AM
  2. Replies: 2
    Last Post: 01-15-2011, 10:56 AM
  3. Replies: 7
    Last Post: 01-12-2011, 08:59 AM
  4. Open form to filtered records
    By ducecoop in forum Access
    Replies: 3
    Last Post: 10-22-2010, 10:53 AM
  5. Filtered Report
    By Desstro in forum Reports
    Replies: 3
    Last Post: 06-18-2010, 09:09 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