Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to close a report if no data

Status
Not open for further replies.

mikemike

Technical User
Jan 3, 2002
2
US
If my client's data range contains no data, and he opens a report...an obnoxious built in message says "no data". Despite adding cancel=-1 to open report method, it crashes. How do I have it: if a report has no data, I wish the report (with code you advise me) to close the report-how do I do this??
 
Try adding this code to the OnNoData event procedure of the report:

Private Sub Report_NoData(Cancel As Integer)

Dim strMsg As String, strTitle As String
Dim intStyle As Integer

strMsg = "There are currently no records"
intStyle = vbOKOnly
strTitle = "Database Name"

MsgBox strMsg, intStyle, strTitle
Cancel = True

End Sub
Linda Adams
Visit my web site for writing and Microsoft Word tips:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top