By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,578 Members | 855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,578 IT Pros & Developers. It's quick & easy.

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

P: 7

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.

Feb 11 '08 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 2.5K+
P: 2,545
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Click()
    Dim stDocName As String
  2. stDocName = "ACT001" ' change this to the name of your report
  3. '
  4. ' change the control name to the name of the search control in your
  5. ' form, and apply whatever filter is appropriate for your circumstances
  6. '
  7. If Me.First_Dept = "*" Then
    DoCmd.OpenReport stDocName, acPreview
    DoCmd.OpenReport stDocName, acPreview, , "[Sequence No] between " & Me.First_Dept.Column(4) & " AND " & Me.Last_Dept.Column(4)
    End IfEnd Sub

Feb 12 '08 #2

P: 7
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.
Feb 13 '08 #3

Expert Mod 2.5K+
P: 2,545
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.

Feb 14 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.