Closing A Report

D

DS

I have on the On Close Property of a report preview, a form opens asking you
if you want to print or just close. This works fine except when there is No
data. The form still opens. Is there a way to stop this poping up if there
is no data or do I need it on another event instead of close.
Thanks
DS
 
A

Al Campagna

DS,
Probably a better solution would be to ditch the pop up form. The
normal way to accomplish what you want is to open the report in Preview, and
let the user use the Menu Bar to Print, or Close, the report. You could
even create a custom report preview menu... with just a Close or Print icon,
if security is an issue.

First... here's a routine to handle a NoData situation

In your form, on the button Click event...

Private Sub cmdRunMyReport_Click()
On Error Resume Next
DoCmd.OpenReport "rptYourReportNme", acViewPreview
End Sub

Then on the report's NoData event....

Private Sub Report_NoData(Cancel As Integer)
Beep
"There are no records that match the criteria."
MsgBox "There are no records that match the criteria.", vbOKOnly
Cancel = True
End Sub

You could use the NoData event to set a variable like DontShowPopUp =
True.
Then... in the Close event code, use an IF statement to not show the
pop-up if DontShowPopUp = True
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 

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