Question : macro to only output if there are records in table

Hi, I have a macro that outputs a report to print. I dont want it to output if there are no records, because I dont want to waste paper. Please advise. I am familiar with Access, but do not know VBA. thank you very much, Nathaniel

Answer : macro to only output if there are records in table

I added the Cancel = True to the report's NoData event.

Because the tables are (mostly) ODBC-linked, I could not fully test, but this may work.

I normally run my reports from a form, using the Click event of a button (instead of a macro, since I think VBA is more flexible, although more complex, than using macros.) When using VBA and the Click event, I would enter the event as this:

Private Sub MyButton_Click()
On Error Resume Next
DoCmd.OpenReport "MyReport", acViewPreview
End Sub
 
App with report NoData event.
 
Random Solutions  
 
programming4us programming4us