How to save report from code......

  • Thread starter Thread starter paul
  • Start date Start date
P

paul

I have a form with eight buttons on it and when click it will open a report
and assign the "Record Source" to that report. It is the same report I use
for all the buttons on the form. Everything is working fine except when
closing the report, it pops up a windows asking to save the report. How to
use code on the "On Close" event on the report to save the report, it does
not matter to select "yes" or "no" in the pop up window,

The code I use to open the report in the form as follow;

docmd.openreport "Rpt1", acDesign
Reports!Rpt1.RecordSource="Select......................"
docmd.oopenreport "Rpt1", acPreview

Thnaks
 
Suggestions inserted below.
I have a form with eight buttons on it and when click it will open a report
and assign the "Record Source" to that report. It is the same report I use
for all the buttons on the form. Everything is working fine except when
closing the report, it pops up a windows asking to save the report. How to
use code on the "On Close" event on the report to save the report, it does
not matter to select "yes" or "no" in the pop up window,

The code I use to open the report in the form as follow;

docmd.openreport "Rpt1", acDesign
Reports!Rpt1.RecordSource="Select......................"

'Close the report and include the "Save" argument
DoCmd.Close acReport, "Rpt1",acSaveYes

.... or ...

'Just save the report
DoCmd.Save acReport,"Rpt1"
 
If you just want to temporarily change the Record Source
of the report during runtime, you do not need to open the
report in design mode. Just open the report in Preview or
Print mode and set the Record Source in the OnOpen event
of the report.
 
Back
Top