Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help refining a routine for printing multiple reports

Status
Not open for further replies.

MoDiggity

Technical User
Dec 14, 2002
20
US
Objective:
1. I now have a total of eight 1 page reports: (RM_Page_1, RM_Page_2,RM_Page_3...etc)

2a. I want to be able to select a button to print all eight reports based on the current record appearing on my form.

2b. I also want to be able to filter all the records based on several criteria, and then print all 8 reports (collated) for each record that matches the selected criteria.

Here's the code and what it does/is doing:
I've shortened it to 3 reports for testing)

The "On Click" event of my button code:

*****************************************
Private Sub Command378_Click()
On Error GoTo Err_Command378_Click

Call CollReports2(5, "RM_Page_1", "RM_Page_2","RM_Page_3")
Exit_Command378_Click:
Exit Sub
Err_Command378_Click:
MsgBox Err.Description
Resume Exit_Command378_Click
End Sub
*****************************************

In the above code - I'm not certain of how to modify the (5, or exactly what that number really does. It is supposed to set the maximum number of pages in each report, which now is only 1, but if I choose 1, only 1 record will print...

The Module Code:

******************************************

Function CollReports2(NumPages, RM_Page_1 As String, RM_Page_2 As String, RM_Page_3 As String)

Dim MyPageNum As Integer

' Set the page number loop and alternate printing the report pages.

For MyPageNum = 1 To NumPages

' NumPages is the number of pages to print.


DoCmd.SelectObject acReport, RM_Page_1, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, RM_Page_2, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, RM_Page_3, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum

Next MyPageNum

End Function

************************************8

1st question. Although this works, each report requeries the data so that if I try to put a criteria "Like" expression into the query I have to input the parameter 8 times, how can I fix that so that the dialog will only appear once and then complete the print job?

2nd Question. What do I need to insert into the code in order to print the 8 reports for the current record appearing on the form?

Thanks to any and all suggestions...
 
1st question. Although this works, each report requeries the data so that if I try to put a criteria "Like" expression into the query I have to input the parameter 8 times, how can I fix that so that the dialog will only appear once and then complete the print job?
if i understand this all the 8 reports print with the same query and the same like this time and the next time all 8 with a diffrent like
try this
in the query grid criteria on the field that you want to put a like clause like forms!formname!txtlike & "*"
and on your from put a text box called txtlike and before you cilck on the command botton enter your like criteria and it will be good for all 8 times


2nd Question. What do I need to insert into the code in order to print the 8 reports for the current record appearing on the form?
Call CollReports2(5)
Function CollReports2(NumPages)

Dim MyPageNum As Integer

' Set the page number loop and alternate printing the report pages.

For MyPageNum = 1 To NumPages

' NumPages is the number of pages to print.

' this will loop and print 5 times
DoCmd.SelectObject acReport, "RM_Page_"& MyPageNum, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum


Next MyPageNum

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top