Blank Report

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

If you have a group of Reports strung together to Print and one of the
reports in the series doesn't have any info how do you get it not to
print and just go to the next report with info?
Thanks
DS
 
You would put some code in the "On No Data" event to close the current
report and open the next.
DS
 
Dan said:
You would put some code in the "On No Data" event to close the current
report and open the next.
DS
So I would do a DCount and if the it =0 close the report and if it
equalled >0 continue?
Thanks
DS
 
Dan said:
You would put some code in the "On No Data" event to close the current
report and open the next.
DS
I tried putting this on the "No Data" event of the Report...
DoCmd.Close acreport, "rptBar"
It said that this command was unavalable....so I tried
DoCmd.CancelEvent
This gave me a Messagebox "This has been cancelled" which didn't open
the report but it also interrupted my code to close the form from which
I'm calling this from.

Private Sub Command148_Click()
On Error GoTo Err_Command148_Click
DoCmd.OpenReport "rptKitchenHot", acViewPreview, , "[SalesID] = " &
Me.SalesID
DoCmd.OpenReport "rptBar", acViewPreview, , "[SalesID] = " & Me.SalesID
DoCmd.Close acForm, "Sales"
Exit_Command148_Click:
Exit Sub

Err_Command148_Click:
MsgBox Err.Description
Resume Exit_Command148_Click

End Sub

Thanks
DS
 
DS said:
Dan said:
You would put some code in the "On No Data" event to close the current
report and open the next.
DS
I tried putting this on the "No Data" event of the Report...
DoCmd.Close acreport, "rptBar"
It said that this command was unavalable....so I tried
DoCmd.CancelEvent
This gave me a Messagebox "This has been cancelled" which didn't
open the report but it also interrupted my code to close the form from
which I'm calling this from.

Private Sub Command148_Click()
On Error GoTo Err_Command148_Click
DoCmd.OpenReport "rptKitchenHot", acViewPreview, , "[SalesID] = " &
Me.SalesID
DoCmd.OpenReport "rptBar", acViewPreview, , "[SalesID] = " & Me.SalesID
DoCmd.Close acForm, "Sales"
Exit_Command148_Click:
Exit Sub

Err_Command148_Click:
MsgBox Err.Description
Resume Exit_Command148_Click

End Sub

Thanks
DS
I have this and it almost works except I can't get the error message
from poping up.

Private Sub Report_NoData(Cancel As Integer)
Cancel = True
DoCmd.Close acForm, "Sales"
Response = acDataErrContinue
End Sub

Thanks
DS
 
DS said:
DS said:
Dan said:
You would put some code in the "On No Data" event to close the current
report and open the next.
DS


If you have a group of Reports strung together to Print and one of the
reports in the series doesn't have any info how do you get it not to
print and just go to the next report with info?
Thanks
DS
I tried putting this on the "No Data" event of the Report...
DoCmd.Close acreport, "rptBar"
It said that this command was unavalable....so I tried
DoCmd.CancelEvent
This gave me a Messagebox "This has been cancelled" which didn't
open the report but it also interrupted my code to close the form from
which I'm calling this from.

Private Sub Command148_Click()
On Error GoTo Err_Command148_Click
DoCmd.OpenReport "rptKitchenHot", acViewPreview, , "[SalesID] = "
& Me.SalesID
DoCmd.OpenReport "rptBar", acViewPreview, , "[SalesID] = " &
Me.SalesID
DoCmd.Close acForm, "Sales"
Exit_Command148_Click:
Exit Sub

Err_Command148_Click:
MsgBox Err.Description
Resume Exit_Command148_Click

End Sub

Thanks
DS

I have this and it almost works except I can't get the error message
from poping up.

Private Sub Report_NoData(Cancel As Integer)
Cancel = True
DoCmd.Close acForm, "Sales"
Response = acDataErrContinue
End Sub

Thanks
DS
OK, I have this, it kills the 2501 message, the problem is that it only
works with one report. If I add a second report, well if the first
report has no info and the second does, it closes everything. How do
you use this 2501 erroe trap with multiple report printouts?
Thanks
DS

Private Sub cmdReport_Click()

On Error GoTo Err_Handler

DoCmd.OpenReport "rptBar", acViewPreview, , "[SalesID] = " &
Me.SalesID

DoCmd.OpenReport "rptKitchenHot", acViewPreview, , "[SalesID] = " &
Me.SalesID

DoCmd.Close acform,"Sales"

Exit_Handler:
Exit Sub

Err_Handler:

Select Case Err.Number

Case 2501

Case Else
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number

End Select

Resume Exit_Handler

End Sub
 
DS said:
DS said:
DS said:
Dan wrote:

You would put some code in the "On No Data" event to close the current
report and open the next.
DS


If you have a group of Reports strung together to Print and one of the
reports in the series doesn't have any info how do you get it not to
print and just go to the next report with info?
Thanks
DS






I tried putting this on the "No Data" event of the Report...
DoCmd.Close acreport, "rptBar"
It said that this command was unavalable....so I tried
DoCmd.CancelEvent
This gave me a Messagebox "This has been cancelled" which didn't
open the report but it also interrupted my code to close the form
from which I'm calling this from.

Private Sub Command148_Click()
On Error GoTo Err_Command148_Click
DoCmd.OpenReport "rptKitchenHot", acViewPreview, , "[SalesID] = "
& Me.SalesID
DoCmd.OpenReport "rptBar", acViewPreview, , "[SalesID] = " &
Me.SalesID
DoCmd.Close acForm, "Sales"
Exit_Command148_Click:
Exit Sub

Err_Command148_Click:
MsgBox Err.Description
Resume Exit_Command148_Click

End Sub

Thanks
DS


I have this and it almost works except I can't get the error message
from poping up.

Private Sub Report_NoData(Cancel As Integer)
Cancel = True
DoCmd.Close acForm, "Sales"
Response = acDataErrContinue
End Sub

Thanks
DS

OK, I have this, it kills the 2501 message, the problem is that it only
works with one report. If I add a second report, well if the first
report has no info and the second does, it closes everything. How do
you use this 2501 erroe trap with multiple report printouts?
Thanks
DS

Private Sub cmdReport_Click()

On Error GoTo Err_Handler

DoCmd.OpenReport "rptBar", acViewPreview, , "[SalesID] = " &
Me.SalesID

DoCmd.OpenReport "rptKitchenHot", acViewPreview, , "[SalesID] = "
&
Me.SalesID

DoCmd.Close acform,"Sales"

Exit_Handler:
Exit Sub

Err_Handler:

Select Case Err.Number

Case 2501

Case Else
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number

End Select

Resume Exit_Handler

End Sub

The answer has been found! Here it vis for future reference.
Thank you
DS

Private Sub Command148_Click()
On Error Resume Next
DoCmd.OpenReport "rptBar", acViewPreview, , "[SalesID] = " & Me.SalesID
DoCmd.OpenReport "rptKitchenHot", acViewPreview, , "[SalesID] = " &
Me.SalesID
DoCmd.Close acForm, "Sales"
If Err = 2501 Then Err.Clear

End Sub
 
Back
Top