Can't Print Filtered Report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eye707
    New Member
    • Mar 2013
    • 32

    Can't Print Filtered Report

    I created a form to choose records by last name. After selecting the name with a combo box, I want the command button to open a report with just that record (or those records) showing. When it opens the report, all the records are showing. I don't know how to filter the query associated with the report so that it selects according to the selection in the combo box (Access 2010). Thanks for any help!
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    The query that your report is based on needs to have a WHERE clause that matches up your Last Name field to the combo box. To reference the control, the syntax is
    Code:
    Forms![I]Form_Name[/I]![I]ControlName[/I]

    Comment

    • eye707
      New Member
      • Mar 2013
      • 32

      #3
      That worked great in the query. The query AND the report work great, what I can't get to work is the command button on my search form. I select a name from the drop down box (combo) on my search form, then I click the command button, which I want to open the report based on the name now showing in the combo box, but it just brings up and empty report form...what am I doing wrong with that command button?

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        Hard to say since I can't see your code. Please provide your entire button's OnClick event code (using Code tags. See Before Posting (VBA or SQL) Code).

        Comment

        • eye707
          New Member
          • Mar 2013
          • 32

          #5
          I'm a newbie when it comes to this ... is this it?
          Option Compare Database

          Private Sub OpenLastNamerep ort_Click()

          End Sub

          Private Sub Form_Click()

          End Sub

          Comment

          • eye707
            New Member
            • Mar 2013
            • 32

            #6
            Seth, thank you so much for your help. I have a 4PM meeting, so I won't be back on here right away. I will get back to any further help you give me when I can!

            Comment

            • Seth Schrock
              Recognized Expert Specialist
              • Dec 2010
              • 2965

              #7
              If you go into go into design view of your form and click on your button, open the properties window and go to the Events tab. Does the On Click event say Event Procedure or Event Macro? Click on it and then click on the elipsis button (the three dots). This will either open the VBA editor or the Macro editor. Either way, it will take you to what is opening the form, which is what I'm after.

              Comment

              • eye707
                New Member
                • Mar 2013
                • 32

                #8
                Hi, Seth,

                Sorry for the long time in responding! I opened the Events tab; it has a macro to open and view my report; there's no WHERE condition in the macro...

                Comment

                • Seth Schrock
                  Recognized Expert Specialist
                  • Dec 2010
                  • 2965

                  #9
                  Okay. Before I have you delete the macro (to use VBA instead), can you list the commands in the macro so that we can make sure that all the functions of the macro are performed when we use VBA?

                  Comment

                  • eye707
                    New Member
                    • Mar 2013
                    • 32

                    #10
                    I'll tgry whatever you suggest at this point!

                    Comment

                    • Seth Schrock
                      Recognized Expert Specialist
                      • Dec 2010
                      • 2965

                      #11
                      I need the information from the macro. Can you tell me all the commands in the macro? For example
                      Code:
                      OpenReport
                      Report Name ...
                      View...
                      Filter Name...
                      Where Condition = ...
                      Window Mode...

                      Comment

                      • zmbd
                        Recognized Expert Moderator Expert
                        • Mar 2012
                        • 5501

                        #12
                        eye707:
                        You will be posting code to this thread so you may want to have this thread open and scrolled down to the reply box

                        Please open the macro in design mode.
                        While in design mode select one line of the macro code.
                        Press <ctrl><a> this will select all of the lines of your macro code.
                        Press <ctrl><c> this will copy all of your macro code to the clipboard.

                        In this thread:
                        Click on the [CODE/] button in the menu, you will see the two [CODE] [/CODE] tags.
                        Click/place the cusor between the tags and <ctrl><v> to past the macro code to the site. You will get something that looks like this: [CODE]<?xml version="1.0" encoding="UTF-16" standalone="no" ?><UserInterfac eMacros xmlns="http://schemas.microso ft.com/office/accessservices/2009/11/application"><U serInterfaceMac ro MinimumClientDe signVersion="14 .0.0000.0000">< Statements/><Sub Name="Sub1">
                        [z{remainder omitted}][/CODE]

                        You can step the code if you like; however, if you will just post the macro one of us may do this for you the first time so that you can see how it's done.

                        Thnx

                        Comment

                        • Seth Schrock
                          Recognized Expert Specialist
                          • Dec 2010
                          • 2965

                          #13
                          I didn't know that you could do that Z. That is nice to know.

                          Comment

                          • eye707
                            New Member
                            • Mar 2013
                            • 32

                            #14
                            This is all that it says:

                            Code:
                            <?xml version="1.0" encoding="UTF-16" standalone="no"?>
                               <UserInterfaceMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application">
                               <UserInterfaceMacro For="OpenLastNameReport" Event="OnClick">
                                  <Statements>
                                     <Action Name="OpenReport">
                                        <Argument Name="ReportName">
                                           INFOreport
                                        </Argument>
                                     </Action>
                                  </Statements>
                               </UserInterfaceMacro>
                            </UserInterfaceMacros>
                            Last edited by zmbd; Mar 11 '13, 01:53 PM. Reason: [z{placed required code}{stepped code}]

                            Comment

                            • eye707
                              New Member
                              • Mar 2013
                              • 32

                              #15
                              Do you want to see the information from the report (the query it's based on?)

                              Comment

                              Working...