How do I report no data found in query, other than a blank page?

P

Percy

I am writting a general query builder and need to report to the user that
their query did not return any records. Just a blank piece of paper in not
acceptable.
 
R

roadie.girl

You may want to put a function behind your form ....

(untested but it would be similar)
Private Sub myReport OnLoad()
If myRS.EOF Then
MsgBox "There were no results for this query. Please try again with
more data"
DoCmd.Close acReport, "MyReport"
End If
End Sub

hth
 
C

chris.nebinger

Or, use the OnNoData event of the report.


Private Sub Report_NoData(Cancel As Integer)
MsgBox "This report contains no data"
Cancel = True
End Sub


You might get an error on the line of code that you used to open the
report.


Chris Nebinger
 
G

guido via AccessMonster.com

You can also (depending on you application), catch the error before the
report is run by checking the query for records:

If (CurrentDb.OpenRecordset("Query2").RecordCount = 0) Then
MsgBox ("There are no records available")
Else
open query or report
End If
 
Top