Save report letters to file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am running a report that generates about 10 letters and I want each letter
to be filed as a separate document to a different location. Can I use the
"OutputTo" option and just put a field name in for the location?
 
Judith,

No, not really. You can refer to the name of a form control in the
Output File argument of the OutputTo action, using syntax like this...
="C:\YourFolder\" & [YourField] & ".snp"
But you would have to run the macro from a continuous view form that is
bound to the record source that contains the data you want to use in the
file name, and use a GoToRecord/Next action as well, and then run the
macro once for each record in the form.

In the end, it is easier to use a VBA procedure to do this sort of stuff.
 
I was beginning to think i would have to resort to VBA.
Would I do something like

....Loop through records in query
....save report for individual record (i really want these as Word documents)

I am a bit hazy, first of all how do i loop through the records of a query
also how do I pass a single record (the one in focus) to a report
Any quick suggestions to get me going would be very helpful
Thanks

Steve Schapel said:
Judith,

No, not really. You can refer to the name of a form control in the
Output File argument of the OutputTo action, using syntax like this...
="C:\YourFolder\" & [YourField] & ".snp"
But you would have to run the macro from a continuous view form that is
bound to the record source that contains the data you want to use in the
file name, and use a GoToRecord/Next action as well, and then run the
macro once for each record in the form.

In the end, it is easier to use a VBA procedure to do this sort of stuff.

--
Steve Schapel, Microsoft Access MVP

I am running a report that generates about 10 letters and I want each letter
to be filed as a separate document to a different location. Can I use the
"OutputTo" option and just put a field name in for the location?
 
Judith

I would approach this by looping through a recordset derived from the
query, something like this...

Dim dbs As Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim BaseSQL As String
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("YourQuery")
Set rst = qdf.OpenRecordset()
BaseSQL = qdf.SQL
Do Until rst.EOF
qdf.SQL = Left(BaseSQL, Len(BaseSQL)-3) & " WHERE YourID =" &
rst!YourID
DoCmd.OutputTo acReport, "YourReport", "RichTextFormat(*.rtf)",
"C:\YourFolder\'" & !YourField & "'.rtf", False
Loop
rst.Close
Set rst = Nothing
qdf.SQL = BaseSQL
Set qdf = Nothing
Set dbs = Nothing
 
Thanks so much for getting me started

Steve Schapel said:
Judith

I would approach this by looping through a recordset derived from the
query, something like this...

Dim dbs As Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim BaseSQL As String
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("YourQuery")
Set rst = qdf.OpenRecordset()
BaseSQL = qdf.SQL
Do Until rst.EOF
qdf.SQL = Left(BaseSQL, Len(BaseSQL)-3) & " WHERE YourID =" &
rst!YourID
DoCmd.OutputTo acReport, "YourReport", "RichTextFormat(*.rtf)",
"C:\YourFolder\'" & !YourField & "'.rtf", False
Loop
rst.Close
Set rst = Nothing
qdf.SQL = BaseSQL
Set qdf = Nothing
Set dbs = Nothing
 
Back
Top