Export a report (without opening it)

  • Thread starter NoLegalMoves via AccessMonster.com
  • Start date
N

NoLegalMoves via AccessMonster.com

I have a form which has a button that should export the values of the
corresponding report to a snapshot file. (The file name is based on the
report name to which I added the value of a filed in my form (to
differenciate each exported report))
I would like this to happen without opening the report if possible.
I have the following code so far. It returns the error that the report is not
opened or misspelled.
I have tried to open the report, export then close the report, but it is
still not working..
report name : RP_Processing


Private Sub Export_Click()
On Error GoTo Err_Export_Click

Dim stDocName As String
Dim filepath As String
Dim strFieldName As String
Dim strRpt As String 'name of Access report


filepath = "C:\Batch info\" & "RP_Processing" & " " & Reports!
[RP_Processing]![Production order #] & ".snp"

strRpt = "RP_Processing"

DoCmd.OutputTo acOutputReport, strRpt, "Snapshot Format", filepath, False


Exit_Export_Click:
Exit Sub

Err_Export_Click:
MsgBox Err.Description
Resume Exit_Export_Click

End Sub
 
J

jfsauzeat129 via AccessMonster.com

Ok, I found my error..
I ll post my findings in case it helps someone.
In the file name of the file I am exporting I look up a field in the
corresponding report.
I replaced it with a look up of the field in the form instead.

It now works fine.

Thanks for reading

I have a form which has a button that should export the values of the
corresponding report to a snapshot file. (The file name is based on the
report name to which I added the value of a filed in my form (to
differenciate each exported report))
I would like this to happen without opening the report if possible.
I have the following code so far. It returns the error that the report is not
opened or misspelled.
I have tried to open the report, export then close the report, but it is
still not working..
report name : RP_Processing

Private Sub Export_Click()
On Error GoTo Err_Export_Click

Dim stDocName As String
Dim filepath As String
Dim strFieldName As String
Dim strRpt As String 'name of Access report

filepath = "C:\Batch info\" & "RP_Processing" & " " & Reports!
[RP_Processing]![Production order #] & ".snp"

strRpt = "RP_Processing"

DoCmd.OutputTo acOutputReport, strRpt, "Snapshot Format", filepath, False

Exit_Export_Click:
Exit Sub

Err_Export_Click:
MsgBox Err.Description
Resume Exit_Export_Click

End Sub
 

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