I have a report that gets it's data from a query. The criteria for this query is specified in a form. When there is no data in the report as a result of the criteria given I would like the report to close and not run.
To do this I put this code in
Private Sub Report_Open(Cancel As Integer)
On Error Resume Next
DoCmd.OpenReport "Rpt_HoursOfClientActivitybyOrganisation"
If Err.Number <> 0 Then If Err.Number <> 2501 Then MsgBox Err.Number & vbNewLine & Err.Description
On Error GoTo 0
End Sub
Theres two things that are going wrong
1. As soon as I click the OK button on the form after entering the criteria - the report prints out!!!
2. I get an error when there is no data.
Are they two seperate errors or do they have something to do with each other?!?!?!
Thanks in advance
Gillian![[pc2] [pc2] [pc2]](/data/assets/smilies/pc2.gif)
To do this I put this code in
Private Sub Report_Open(Cancel As Integer)
On Error Resume Next
DoCmd.OpenReport "Rpt_HoursOfClientActivitybyOrganisation"
If Err.Number <> 0 Then If Err.Number <> 2501 Then MsgBox Err.Number & vbNewLine & Err.Description
On Error GoTo 0
End Sub
Theres two things that are going wrong
1. As soon as I click the OK button on the form after entering the criteria - the report prints out!!!
2. I get an error when there is no data.
Are they two seperate errors or do they have something to do with each other?!?!?!
Thanks in advance
Gillian
![[pc2] [pc2] [pc2]](/data/assets/smilies/pc2.gif)