Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using sendobject with a snapshot report

Status
Not open for further replies.

tdfreeman

MIS
Mar 28, 2002
85
US
I have a problem. I have a database where I create two reports. I output them as snapshots, which works. I then create an email, through Lotus Notes to send a snapshot of the report.

My problem is with the attachment of the object. For one report it works fine, for another it doesn't. My code to run, save and send the report that isn't attaching a valid copy of the report to the email is:

Private Sub cmdRunReport_Click()
On Error GoTo Err_cmdRunReport_Click

Dim stDocName As String
Dim strAttach As String

stDocName = "Document Status"
strAttach = "C:\My_Data\JFMIP\DocStatus\Output\DS_Cycle" & Forms!frmDSSwitchboard!txtCycle & ".snp"
DoCmd.OpenReport stDocName, acPreview
DoCmd.OutputTo acOutputReport, stDocName, acFormatSNP, strAttach, True
DoCmd.SendObject acSendReport, stDocName, "Snapshot Format", "JFMIP Document Status", , , _
"Document Status Report for Cycle " & Forms!frmDSSwitchboard!txtCycle

Exit_cmdRunReport_Click:
Exit Sub

Err_cmdRunReport_Click:
MsgBox Err.Description
Resume Exit_cmdRunReport_Click

End Sub


My code to run, save and send the report that is attaching a valid copy of the report to the email is:

Private Sub cmdRunReport_Click()
On Error GoTo Err_cmdRunReport_Click

Dim stDocName As String
Dim strSave As String

stDocName = "FA_Merge_All"
DoCmd.OpenReport stDocName, acPreview
strSave = InputBox("Do you want to save the report? Y/N")
'If strSave = "y" Or strSave = "Y" Then
' DoCmd.OutputTo acOutputReport, stDocName, acFormatRTF, _
' "C:\My_Data\JFMIP\Funds_Av_Rpts\Compares\FA_Merge_C" & Forms!frmFASwitchboard!txtCycle & ".rtf", True
'End If
If strSave = "y" Or strSave = "Y" Then
DoCmd.OutputTo acOutputReport, stDocName, acFormatSNP, _
"C:\My_Data\JFMIP\Funds_Av_Rpts\Compares\FA_Cycle" & Forms!frmFASwitchboard!txtCycle & ".snp", True
DoCmd.SendObject acSendReport, strDocName, "Snapshot Format", "JFMIP Funds Availability", , , _
"Funds Availability Report for Cycle " & Forms!frmFASwitchboard!txtCycle
End If

Exit_cmdRunReport_Click:
Exit Sub

Err_cmdRunReport_Click:
MsgBox Err.Description
Resume Exit_cmdRunReport_Click

End Sub

The Document Status report is not attaching to the email. An Excel file with garbage in it is attaching. I don't understand. This is the same database and the same commands. Also, the Document Status worked earlier.

The only change that I can think about that I made to the Document Status report was add a running sum text box that put a number on each line in order to number the report. However, I took it off and tried to run the code again and I still get the same problem. I have also tried compacting and repairing the database. That doesn't help either.

Thank you for your help.

Tammy
Thank you for your help.

Tammy
 
I have always used "SnapshotFormat(*.snp)" as the Format parameter in the SendObjects command. You have used acFormatSNP.

Give it a try. Bob Scriver
 
More likely you are running this in Access 2000 and have fallen foul of a bug with SendObject - this seems especially likely given the symptom that your code works first time round but not for the second report. Read more about this at - Micro$oft even propose a (somewhat limited) workaround. However, there's a functionally richer workaround that supports attachments at - what you'll then need to do with this code is:

1. Export your report as a snapshot file
2. Send a mail using the code from the Brinkster link, above, attaching the exported file
3. Delete the exported file. [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top