Printing reports

D

dhoover

I have a button on a form that prints a group of reports. I need to be able
to tell it that if the report has no data, skip it and move to the next
report. The problem is that each report has a date at the top and access is
assuming that qualifies as data, and print empty pages with a data at the top.
Is there a way around this?
 
J

Jeff Boyce

Could you post the SQL statement your button is using to print the "group of
reports"? How you are doing this now could offer approaches to what you
want to change.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
D

dsc2bjn

Try adding the following code to the OnFormat parameter of the Detail section
of each report:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

On Error GoTo Detail_Format_Error

' Choose a color based on the shadeNextRow value
If shadeNextRow = True Then
Me.Section(acDetail).BackColor = shadedColor
Else
Me.Section(acDetail).BackColor = normalColor
End If

' Switch the color for the next row
shadeNextRow = Not shadeNextRow

Detail_Format_Exit:
Exit Sub

Detail_Format_Error:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Detail_Format_Exit

End Sub
 
D

dhoover

This is the code



Private Sub cmdAdvPrint_Click()
On Error GoTo Err_cmdAdvPrint_Click

Dim stDocName As String

'Advance Credit Tickets
stDocName = "Deposit Advance Ticket"
DoCmd.OpenReport stDocName, acNormal

'Advance Debit Tickets
stDocName = "General Ledger Debit Advance Ticket"
DoCmd.OpenReport stDocName, acNormal

stDocName = "Business Loan Debit Advance Ticket"
DoCmd.OpenReport stDocName, acViewNormal


Exit_cmdAdvPrint_Click:
Exit Sub

Err_cmdAdvPrint_Click:
MsgBox Err.Description
Resume Exit_cmdAdvPrint_Click

End Sub

Jeff said:
Could you post the SQL statement your button is using to print the "group of
reports"? How you are doing this now could offer approaches to what you
want to change.

Regards

Jeff Boyce
Microsoft Office/Access MVP
I have a button on a form that prints a group of reports. I need to be
able
[quoted text clipped - 4 lines]
top.
Is there a way around this?
 
J

Jeff Boyce

Depending on the version of Access you are using, your reports should have a
NoData event. You could add code in each report's NoData event that
canceled/closed the report.

You'd need to add error-handling code to your <command button> to intercept
the "this report was closed" error message (?2501 = err.number?) and resume
processing at the next report in the command button's code..

Good luck!

Jeff Boyce
Microsoft Office/Access

dhoover said:
This is the code



Private Sub cmdAdvPrint_Click()
On Error GoTo Err_cmdAdvPrint_Click

Dim stDocName As String

'Advance Credit Tickets
stDocName = "Deposit Advance Ticket"
DoCmd.OpenReport stDocName, acNormal

'Advance Debit Tickets
stDocName = "General Ledger Debit Advance Ticket"
DoCmd.OpenReport stDocName, acNormal

stDocName = "Business Loan Debit Advance Ticket"
DoCmd.OpenReport stDocName, acViewNormal


Exit_cmdAdvPrint_Click:
Exit Sub

Err_cmdAdvPrint_Click:
MsgBox Err.Description
Resume Exit_cmdAdvPrint_Click

End Sub

Jeff said:
Could you post the SQL statement your button is using to print the "group
of
reports"? How you are doing this now could offer approaches to what you
want to change.

Regards

Jeff Boyce
Microsoft Office/Access MVP
I have a button on a form that prints a group of reports. I need to be
able
[quoted text clipped - 4 lines]
top.
Is there a way around this?
 

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