I have some code modified from the Microsoft knowledge base. I have a 7 page report that I need to collate and print to 300 people. The code that I have (and it works) is:
Function CollateReports(NumPages, Rpt1 As String, Rpt2 As String, Rpt3 As String, Rpt4 As String, Rpt5 As String, Rpt6 As String, Rpt7 As String)
Dim MyPageNum As Integer
'Set the page number loop and alternate printing the report pages.
For MyPageNum = 1 To 5 'if you input 1 to 5, it will print and collate the first 5 records of each report
'NumPages is the number of pages to print.
DoCmd.SelectObject acReport, Rpt1, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt2, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt3, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt4, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt5, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt6, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt7, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
Next MyPageNum
End Function
then, I have to go to the immediate window, input the command below, which causes the module to run and print my reports:
?CollateReports(1, "Peds Page 1","Peds Page 2","Peds Page 3","Peds Page 4","Peds Page 5","Peds Page 6","Peds Page 7"
Problem: Data is sent to the printer too fast and everything gets jumbled after awhile. I have searched and found various coding for a 'Wait' or a 'Pause; however, I cannot figure out how to incproprate it into the above code. I get an error every time. The coding for thie (I believe) has to be embedded within the above code somewhere, to cause the program to pause for 30 seconds before it loops and starts again.
Can anyone help me? Please let me know if you need more information. Thank you.
Function CollateReports(NumPages, Rpt1 As String, Rpt2 As String, Rpt3 As String, Rpt4 As String, Rpt5 As String, Rpt6 As String, Rpt7 As String)
Dim MyPageNum As Integer
'Set the page number loop and alternate printing the report pages.
For MyPageNum = 1 To 5 'if you input 1 to 5, it will print and collate the first 5 records of each report
'NumPages is the number of pages to print.
DoCmd.SelectObject acReport, Rpt1, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt2, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt3, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt4, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt5, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt6, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt7, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
Next MyPageNum
End Function
then, I have to go to the immediate window, input the command below, which causes the module to run and print my reports:
?CollateReports(1, "Peds Page 1","Peds Page 2","Peds Page 3","Peds Page 4","Peds Page 5","Peds Page 6","Peds Page 7"
Problem: Data is sent to the printer too fast and everything gets jumbled after awhile. I have searched and found various coding for a 'Wait' or a 'Pause; however, I cannot figure out how to incproprate it into the above code. I get an error every time. The coding for thie (I believe) has to be embedded within the above code somewhere, to cause the program to pause for 30 seconds before it loops and starts again.
Can anyone help me? Please let me know if you need more information. Thank you.