how to save snapshot reports with different names via macro

G

Guest

I have completed a macro that saves multiple reports in snapshot format. The
macro repeats for each consecutive report to be saved. But, I have not been
able to figure out the syntax (if any) to allow the snapshot report to have a
saved file name different than the initial name indicated in the Output File
of the macro.

Is it possible to use the OutputTo, Output File to do this automatically?
 
S

Steve Schapel

SystemsInfo,

Yes, this is possible. Can you please give an example of what you want?
Thanks.
 
G

Guest

I would like to place some type of syntax in the Output File line of the
OutputTo line of the macro.

Example: C:\My Documents\Snapshot Files\FileName.snp

The FileName.snp will have to change each time the macro repeats.

I have tried syntax for the FileName.snp like [Forms]![frm-MassMailing
List].[CustName].snp. It loops ok, but all reports are saved with the one
file name.
 
S

Steve Schapel

SystemsInfo,

If the macro is being called from an event on the frm-MassMailing List
form, you can do like this...
="C:\My Documents\Snapshot Files\" & [CustName] & ".snp"

But are you using a separate OutputTo action for each report? Or What
are the details of what you are doing so far? And how is the macro
supposed to know which CustName to use? If there is supposed to be a
different file produced for each CustName, you may need to use a
GoToRecord/Next action in the macro, or some such, but tat this stage
just shooting in the dark because I can't envisage your setup there.
 
G

Guest

Steve,

Ok, the details are as follows:

Macro A is called via button click.
Macro A: Run Macro B, Repeat 100

Macro B:
1. Open Form frm-MassMailing
View Form
Data Mode Read Only
Window Normal
2. Run Macro
Macro Name Macro C
3. GoTo Record
Object Type Form
Obj Name frm-MassMailing
Record Next
Offset 1

Macro C
1. Open Report
Report Name rpt-MassMailing
View Print Preview
Where Condition (This works fine, and is lengthy, so omit)
2. OutputTo
Object Type Report
Object Name rpt-MassMailing
OutputFormat Snapshot Format
Output File C:\My Documents\Snapshots\CustName.snp
Auto Start No
3. Close
Object Type report
Object Name rpt-MassMailing
Save No


Please note everything works with the exception of the save by CustName.
Each report does save, but each overwrites the previous save due to the Ouput
File. Maybe there is a syntax that will work. I tried the ...\" &
[rpt-MassMailing] & ".snp" but no-go.




Steve Schapel said:
SystemsInfo,

If the macro is being called from an event on the frm-MassMailing List
form, you can do like this...
="C:\My Documents\Snapshot Files\" & [CustName] & ".snp"

But are you using a separate OutputTo action for each report? Or What
are the details of what you are doing so far? And how is the macro
supposed to know which CustName to use? If there is supposed to be a
different file produced for each CustName, you may need to use a
GoToRecord/Next action in the macro, or some such, but tat this stage
just shooting in the dark because I can't envisage your setup there.

--
Steve Schapel, Microsoft Access MVP

I would like to place some type of syntax in the Output File line of the
OutputTo line of the macro.

Example: C:\My Documents\Snapshot Files\FileName.snp

The FileName.snp will have to change each time the macro repeats.

I have tried syntax for the FileName.snp like [Forms]![frm-MassMailing
List].[CustName].snp. It loops ok, but all reports are saved with the one
file name.
 
S

Steve Schapel

SystemsInfo,

Well, it wouldn't be ...\" & [rpt-MassMailing] & ".snp" would it? I
thought you wanted the CustName in the name of the output file? You
already have a GoToRecord/Next action in the macro, so I am guessing
that there is a CustName control on the frm-MassMailing form, no? If
so, I think it would be:
...\" & [Forms]![frm-MassMailing]![CustName] & ".snp"

It is good that you r macro is working otherwise. However, I think
actions 1 and 3 in Macro C are redundant and can be removed. I can see
no advantage in opening the report in Preview mode and then closing it
again. And then I think I would myself be tempted to simplify like this...

Macro A is called via button click.
Macro A:
1. Open Form frm-MassMailing
View Form
Data Mode Read Only
Window Normal
2. Run Macro B, Repeat 100

Macro B:
1. OutputTo
Object Type Report
Object Name rpt-MassMailing
OutputFormat Snapshot Format
Output File ="C:\My Documents\Snapshots\" &
[Forms]![frm-MassMailing]![CustName] & ".snp"
Auto Start No
2. GoTo Record
Object Type Form
Obj Name frm-MassMailing
Record Next

....or, if the button to run this is in fact on the frm-MassMailing form,
like this...

Macro A is called via button click.
Macro A:
1. Run Macro B, Repeat 100

Macro B:
1. OutputTo
Object Type Report
Object Name rpt-MassMailing
OutputFormat Snapshot Format
Output File ="C:\My Documents\Snapshots\" & [CustName] & ".snp"
Auto Start No
2. GoTo Record
Object Type <blank>
Obj Name <blank>
Record Next
 

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