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

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
 
B

Bruce M. Thompson

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"
 
J

Jack

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.
 

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