have a macro in Access that opens 10 different reports. Each report is sent to an output file with a different name. Is there a way to add a field from the report to the outpur file name? Attached is the code.
Option Compare Database
'------------------------------------------------------------
' Accounting_Reports1
'
'------------------------------------------------------------
Function Accounting_Reports1()
On Error GoTo Accounting_Reports1_Err
DoCmd.OutputTo acReport, "4 Telecomm Giro Paisano (Acct Rpt) May 2004", "SnapshotFormat(*.snp)", "g:\user\eporeports\Giro Paisano 022207.snp", False, ""
DoCmd.OutputTo acReport, "4 Telecomm Giro (Acct Rpt) May 2004", "SnapshotFormat(*.snp)", "G:\user\eporeports\Giro Telegrafico 022207.snp", False, ""
DoCmd.OutputTo acReport, "2 Telecomm Trans (Acct Rept) Dia Siguiente May 2004", "SnapshotFormat(*.snp)", "G:\user\eporeports\Dia Siguente 022207.snp", False, ""
DoCmd.OutputTo acReport, "2 Telecomm Trans (Acct Rept) Din Min May 2004", "SnapshotFormat(*.snp)", "G:\user\eporeports\Dinero en Minutos 022207.snp", False, ""
DoCmd.OutputTo acReport, "7 Bital Acct Rep 11xx02", "SnapshotFormat(*.snp)", "G:\user\eporeports\Bital 022207.snp", False, ""
DoCmd.OutputTo acReport, "9 Banamex Foreign Fx adjusted", "SnapshotFormat(*.snp)", "G:\user\eporeports\Banamex Foreign FX 022207.snp", False, ""
DoCmd.OutputTo acReport, "9 Banamex US FX adjusted", "SnapshotFormat(*.snp)", "G:\user\eporeports\Banamex US FX 022207.snp", False, ""
DoCmd.OutputTo acReport, "CEMECA Acct Rept 021904", "SnapshotFormat(*.snp)", "G:\user\eporeports\CEMECA 022207.snp", False, ""
DoCmd.OutputTo acReport, "6 Commercial Mexicana Accounting Report Foreign", "SnapshotFormat(*.snp)", "G:\user\eporeports\Commercial Mexicana Foreign 022207.snp", False, ""
DoCmd.OutputTo acReport, "6 Commercial Mexicana Accounting Report US", "SnapshotFormat(*.snp)", "G:\user\eporeports\Commercial Mexicana US 022207.snp", False, ""
DoCmd.OutputTo acReport, "8 HEB Foreign FX Adjusted", "SnapshotFormat(*.snp)", "G:\user\eporeports\HEB Foreign 022207.snp", False, ""
DoCmd.OutputTo acReport, "8 HEB US FX adjusted", "SnapshotFormat(*.snp)", "G:\user\eporeports\HEB US 022207.snp", False, ""
DoCmd.OutputTo acReport, "AMEX Inbound Accounting Report", "SnapshotFormat(*.snp)", "g:/user/eporeports/Amex Inbound Accounting Report 022207.snp", False, ""
Accounting_Reports1_Exit:
Exit Function
Accounting_Reports1_Err:
MsgBox Error$
Resume Accounting_Reports1_Exit
End Function
>Is there a way to add a field from the report to the outpur file name?
You can always build the destination file name dynamically, like this...
Dim sFolder as String, sFileName as String
sFolder = "G:\user\eporeports\"
sFileName = "Customer1" 'Or whatever you want to feed into it.
DoCmd.OutputTo acReport, "report name-1", "SnapshotFormat(*.snp)", sFolder & sFileName
sFileName = "Customer2" 'Or whatever you want to feed into it.
DoCmd.OutputTo acReport, "report name-2", "SnapshotFormat(*.snp)", sFolder & sFileName
You get the idea.
Hope this helps.
-Jim