Printing Multiple Reports

T

tellier

I have set a button up on a form so the user can print out reports for
distrubution. Depending on the branch it will print different reports out.
Some time a report will have no information on it and I want it to not print
but then continue on to the next reprt.

I have tried adding the "No Data" event to the report but then if one report
at the begining has no data the rest of the reports don't print either.

Here is my code -- Could you make a suggestion on how to do this?
Thanks
Tonia

Private Sub Print_Branch_Const_Packets_Click()
On Error GoTo Err_Print_Branch_Const_Packets_Click

Rem CONSTRUCTION REPORTS

Dim num As Integer

num = 0

While (num < [Number of Reports Wanted])

Dim stDocName As String

Rem Division Reports

stDocName = "Graphs DIV"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Division - Construction - YTD 875000"
DoCmd.OpenReport stDocName, acNormal

Rem Branch Reports

If [City] = "Des Moines" Then

stDocName = "Graphs D"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - Month Detail 875100 D"
DoCmd.OpenReport stDocName, acNormal

Else
End If
If [City] = "Kansas City" Then

stDocName = "Graphs K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - YTD 875100 K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - Month Summary 875100 K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - Month Detail 875100 K"
DoCmd.OpenReport stDocName, acNormal

Else
End If

Let num = num + 1
Wend
 
M

Marshall Barton

tellier said:
I have set a button up on a form so the user can print out reports for
distrubution. Depending on the branch it will print different reports out.
Some time a report will have no information on it and I want it to not print
but then continue on to the next reprt.

I have tried adding the "No Data" event to the report but then if one report
at the begining has no data the rest of the reports don't print either.

Here is my code -- Could you make a suggestion on how to do this?


Private Sub Print_Branch_Const_Packets_Click()
On Error GoTo Err_Print_Branch_Const_Packets_Click

Rem CONSTRUCTION REPORTS

Dim num As Integer

num = 0

While (num < [Number of Reports Wanted])

Dim stDocName As String

Rem Division Reports

stDocName = "Graphs DIV"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Division - Construction - YTD 875000"
DoCmd.OpenReport stDocName, acNormal

Rem Branch Reports

If [City] = "Des Moines" Then

stDocName = "Graphs D"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - Month Detail 875100 D"
DoCmd.OpenReport stDocName, acNormal

Else
End If
If [City] = "Kansas City" Then

stDocName = "Graphs K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - YTD 875100 K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - Month Summary 875100 K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - Month Detail 875100 K"
DoCmd.OpenReport stDocName, acNormal

Else
End If

Let num = num + 1
Wend


Add this to the beginning of the code:

On Error GoTo ErrHandler

Then add this just before the End Sub:

ExitHere:
Exit Sub

ErrHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume ExitHere
End Select

Be sure to check VBA Help for anything you are not familiar
with.
 
T

tellier

Marshall said:
I have set a button up on a form so the user can print out reports for
distrubution. Depending on the branch it will print different reports out.
[quoted text clipped - 58 lines]
Let num = num + 1
Wend

Add this to the beginning of the code:

On Error GoTo ErrHandler

Then add this just before the End Sub:

ExitHere:
Exit Sub

ErrHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume ExitHere
End Select

Be sure to check VBA Help for anything you are not familiar
with.

Hi Marshall,
Thanks for the reply.

Should I add it at the beginning after the --
While (num < [Number of Reports Wanted])
On Error GoTo ErrHandler


and then the rest after --
Wend

Exit_ Branch_Const_Packets _Click:
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume ExitHere
End Select

Err_ Branch_Const_Packets _Click:
MsgBox Err.Description
Resume Exit_Constr_File_Copy_Click

End Sub


Thanks for the help.
 
M

Marshall Barton

tellier said:
Marshall said:
I have set a button up on a form so the user can print out reports for
distrubution. Depending on the branch it will print different reports out.
[quoted text clipped - 58 lines]
Let num = num + 1
Wend

Add this to the beginning of the code:

On Error GoTo ErrHandler

Then add this just before the End Sub:

ExitHere:
Exit Sub

ErrHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume ExitHere
End Select

Be sure to check VBA Help for anything you are not familiar
with.

Hi Marshall,
Thanks for the reply.

Should I add it at the beginning after the --
While (num < [Number of Reports Wanted])
On Error GoTo ErrHandler


and then the rest after --
Wend

Exit_ Branch_Const_Packets _Click:
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume ExitHere
End Select

Err_ Branch_Const_Packets _Click:
MsgBox Err.Description
Resume Exit_Constr_File_Copy_Click

End Sub

I don't think that's right. You better post the entire
procedure. It looks like there is some wizard generated
error handling code already in there so we need to integrate
the new parts and the existing parts.
 
T

tellier via AccessMonster.com

Marshall said:
[quoted text clipped - 49 lines]

I don't think that's right. You better post the entire
procedure. It looks like there is some wizard generated
error handling code already in there so we need to integrate
the new parts and the existing parts.
HI Marshall,
Here is the entire code.
Thanks
Tonia

Private Sub Print_Branch_Const_Packets_Click()
On Error GoTo Err_Print_Branch_Const_Packets_Click

Rem CONSTRUCTION REPORTS

Dim num As Integer

num = 0

While (num < [Number of Reports Wanted])

Dim stDocName As String

Rem Division Reports

stDocName = "Graphs DIV"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Division - Construction - YTD 875000"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Division - Construction - Month 875000"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Division - Construction - YTD 875100"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Division - Construction - Month 875100"
DoCmd.OpenReport stDocName, acNormal

Rem Branch Reports

If [City] = "Des Moines" Then

stDocName = "Graphs D"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - YTD 875000 D"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - YTD 875100 D"
DoCmd.OpenReport stDocName, acNormal

Else
End If

If [City] = "Kansas City" Then

stDocName = "Graphs K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - YTD 875000 K"
DoCmd.OpenReport stDocName, acNormal

Else
End If

If [City] = "Omaha" Then

stDocName = "Graphs O"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - YTD 875000 O"
DoCmd.OpenReport stDocName, acNormal

Else
End If

If [City] = "Wichita" Then

stDocName = "Graphs W"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Construction - YTD 875000 W"
DoCmd.OpenReport stDocName, acNormal

Else
End If

Let num = num + 1
Wend

Exit_Print_Branch_Const_Packets_Click:
Exit Sub

Err_Print_Branch_Const_Packets_Click:
MsgBox Err.Description
Resume Exit_Print_Branch_Const_Packets_Click

End Sub
 
M

Marshall Barton

tellier said:
Marshall said:
I have set a button up on a form so the user can print out reports for
distrubution. Depending on the branch it will print different reports out.
[quoted text clipped - 49 lines]

I don't think that's right. You better post the entire
procedure. It looks like there is some wizard generated
error handling code already in there so we need to integrate
the new parts and the existing parts.

Here is the entire code.

Private Sub Print_Branch_Const_Packets_Click()
On Error GoTo Err_Print_Branch_Const_Packets_Click
[snip procedure's working code]
Exit_Print_Branch_Const_Packets_Click:
Exit Sub

Err_Print_Branch_Const_Packets_Click:
MsgBox Err.Description
Resume Exit_Print_Branch_Const_Packets_Click
End Sub


Ok, now you just need to change the end of the code to:

Err_Print_Branch_Const_Packets_Click:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Description
Resume Exit_Print_Branch_Const_Packets_Click
End Select
End Sub
 
T

tellier via AccessMonster.com

Marshall said:
[quoted text clipped - 11 lines]
Private Sub Print_Branch_Const_Packets_Click()
On Error GoTo Err_Print_Branch_Const_Packets_Click

[snip procedure's working code]
Exit_Print_Branch_Const_Packets_Click:
Exit Sub
[quoted text clipped - 3 lines]
Resume Exit_Print_Branch_Const_Packets_Click
End Sub

Ok, now you just need to change the end of the code to:

Err_Print_Branch_Const_Packets_Click:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Description
Resume Exit_Print_Branch_Const_Packets_Click
End Select
End Sub
Hi Marshall,

I added the code and it still is printing the reports that say "ERROR". Here
is the code after I added it.
Thanks again for all your assitance.
Tonia

Private Sub print_service_divsion_packet_Click()
On Error GoTo Err_print_service_divsion_packet_Click

Rem SERVICE REPORTS

Dim num As Integer

num = 0

While (num < [Number of Reports Wanted])

Dim stDocName As String

Rem Division Reports

stDocName = "Graphs DIV"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Division - Service - YTD 875000"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Division - Service - Month 875000"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Division - Service - YTD 875100"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Division - Service - Month 875100"
DoCmd.OpenReport stDocName, acNormal


Rem Branch Reports

Rem Des Moines

stDocName = "Graphs D"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- YTD 875000 D"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875000 D"
DoCmd.OpenReport stDocName, acNormal

stDocName = "Rpt Des Moines Tech - Service - YTD 875000"
DoCmd.OpenReport stDocName, acNormal

stDocName = "Rpt Des Moines Tech - Service - Month Summary 875000"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- YTD 875100 D"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875100 D"
DoCmd.OpenReport stDocName, acNormal

Rem Des Moines Electrical

stDocName = "RPT Branch - Service- YTD 875000 DE"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875000 DE"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- YTD 875100 DE"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875100 DE"
DoCmd.OpenReport stDocName, acNormal

Rem Kansas City

stDocName = "Graphs K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- YTD 875000 K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875000 K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- YTD 875100 K"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875100 K"
DoCmd.OpenReport stDocName, acNormal

Rem Kansas City Electrical

stDocName = "RPT Branch - Service- YTD 875000 KE"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875000 KE"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- YTD 875100 KE"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875100 KE"
DoCmd.OpenReport stDocName, acNormal

Rem Omaha

stDocName = "Graphs O"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- YTD 875000 O"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875000 O"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- YTD 875100 O"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875100 O"
DoCmd.OpenReport stDocName, acNormal

Rem Wichita

stDocName = "Graphs W"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- YTD 875000 W"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875000 W"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- YTD 875100 W"
DoCmd.OpenReport stDocName, acNormal

stDocName = "RPT Branch - Service- Month Summary 875100 W"
DoCmd.OpenReport stDocName, acNormal


Let num = num + 1

Wend




Exit_print_service_divsion_packet_Click:
Exit Sub

Err_print_service_divsion_packet_Click:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Description
Resume Exit_print_service_divsion_packet_Click
End Select

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top