How do I print a report based off of a continous form's search results?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NMarks
    New Member
    • Feb 2008
    • 7

    How do I print a report based off of a continous form's search results?

    Hello,

    I currently have a continous form that has a search field in the header. The search works without issue, but I want to be able to print a report based off the search results.

    All the records have there own unique Record ID and they are all pulled from the same table.

    I know how to print a report based off 1 record, but I can't for the life of me figure out the above problem.

    Any help would be greatly appreciated.

    I have MS Office - SP2 on Windows Professional.

    Thanks
    Nick
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Depends on how your search works on the form. If your search box applies a filter to the records in your form via the control's after_update event, you can place a report button on the form which will open the report and apply the same filter to the report when it is opened, hence showing the same records. It takes very little programming of the on-click event of the report button.

    Here is an example of a similar technique, used in this case to pick specific departments on which to report. This is from a selection form which uses two combo boxes, first_dept and last_dept, to select from a list of ordered departments. The default for the combos is "*" for show all, and as you will see from the code if this is the combo value the report is opened without a filter.

    If the user selects specific departments the report is opened with a filter condition to show only the reports from the first to the last departments specified.

    [CODE=vb]Private Sub Report_Click()
    Dim stDocName As String
    stDocName = "ACT001" ' change this to the name of your report
    '
    ' change the control name to the name of the search control in your
    ' form, and apply whatever filter is appropriate for your circumstances
    '
    If Me.First_Dept = "*" Then
    DoCmd.OpenRepor t stDocName, acPreview
    Else
    DoCmd.OpenRepor t stDocName, acPreview, , "[Sequence No] between " & Me.First_Dept.C olumn(4) & " AND " & Me.Last_Dept.Co lumn(4)
    End If
    End Sub[/CODE]
    Cheers

    Stewart

    Comment

    • NMarks
      New Member
      • Feb 2008
      • 7

      #3
      The Search is actually done by an On-Click Command.

      I have multiple text boxes allowing a user to search by 4 different items as well as by date range.

      Comment

      • Stewart Ross
        Recognized Expert Moderator Specialist
        • Feb 2008
        • 2545

        #4
        Ok, if it is an on-click response you are presumably building a filter condition or SQL 'Where' clause which filters the dataset based on the values in your text boxes. You should be able to use the same filter or SQL statement to filter your report...

        If you can attach the VBA code for the on-click it would help to clarify next steps.

        -Stewart

        Comment

        Working...