Results 1 to 5 of 5
  1. #1
    jaarons is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    22

    Printing A Filtered Report from a Combo Box

    Hi everyone,

    Hopefully a simple question. I have a table of information of students. One of the fields is called Notes
    I have a form where I have a dropdown list of the students (linked to the StudentsID) and I have a print button
    I have a report designed with a students first name, last name and the notes field

    Ok, so I can easily click on the Print button to show the report of ALL the students, but I only want it to show the report and filter it to a single student that I have picked from the list.
    Is there some programming that could help me with this?

    The report is called: StudentNotes
    The form is called: StudentsNotesView
    The table is called: Students


    The relevant fields are: StudentID_PF, StudentFName, StudentLName, Notes

    Many thanks in advance!

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Make a second report that is based only on a single client. Use the exact same query you're using now to show ALL your students. But in the criteria of the query driving the report put the following (assuming your combo box's key is the same as the student ID key)

    [forms]![StudentsNotesView]![StudentID_PF]

    This assumes the combo box on your form is named StudentID_PF and that the bound column of that combo box is the primary key for the students table.

  3. #3
    jaarons is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    22
    Hey. I think I'm almost there. Tell me if I'm right (or where I'm wrong)

    In the form StudentNotesView, there is a combo box called StudentID_PF.
    The form has a Record Source of qryStudents (a query that just asks for StudentID_PF and Full Name (FullName: [StudentFName] & " " & [StudentLName]) that itself points to a table called Students.
    There is also a button captioned "Print" that has a macro simply to Close Window and then Open Report (StudentNotes)

    I have a query called qryStudentNotes that has, from the Students table, StudentID_PF (using the criteria you mentioned [forms]![StudentNotesView]![StudentID_PF]), Student FName, StudentLName and Notes. I've unchecked Show for StudentID_PF.

    I have a report called StudentNotes that has a Record Source of qryStudentNotes. It has the three fields of StudentFName, StudentLName and Notes all from that query.

    Ok, so on the form StudentNotesView, when I choose from the list of names (which comes nicely with first and second name together: eg: Clark Kent, rather than an obscrure KeyID) and press the Print button I get a parameter value error that points to my criteria asking me for a value.

    So, I've obviously done something wrong. The query connected to the report has the criteria in place to look at the value of the combo box. I'm thinking its the combo box that is somehow setup wrong.

    Can you help?

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Can you post an example database, just make a copy of your existing database, put in some garbage data then compact/repair, zip it up and upload it.

    If you have 'unchecked' the column 'StudentID_PF' in your query qryStudentNotes and that is the data source driving your list of students that you can choose from then that may be the problem. The Combo box or list box must have that ID for the secondary query (the one running your report) or it won't work. You don't want to set the show value to no (an unchecked box) you just want the first column of your combo box or list box to contain that StudentID_PF and set the WIDTH of that column to 0 so that it's not visible but still there. Similar to hiding a column in excel.

  5. #5
    jaarons is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    22
    Its okay. I've worked it out. The problem was in my form there was a button where the macros said to close the window then open the report. Once I swapped it and opened the report, then closed the window, it all worked perfectly.

    Thanks for trying, though.

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

Similar Threads

  1. Replies: 2
    Last Post: 07-28-2014, 01:15 PM
  2. Replies: 3
    Last Post: 11-06-2012, 03:25 PM
  3. Replies: 4
    Last Post: 05-17-2012, 12:28 AM
  4. Replies: 5
    Last Post: 01-02-2011, 10:09 AM
  5. Replies: 0
    Last Post: 09-19-2009, 03:29 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