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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-Time Error while exporting

Status
Not open for further replies.

dataent

Programmer
Jun 19, 2001
29
US
I need to email a report to department heads with only their information. I have a report that I pass the date in from a VB6 application, a list of dept numbers and email addresses are read from a file. The first time through the report works fine, the email goes out. However, the second time through I get: "Run-time error '-2147190908 (80047784)': Failed to export the report" The dept # and email addresses are correctly being extracted from the file.

The error is occuring on the line "Rep.export(false)". I have stripped out some of the extra code and error checking to reduce confussion.

Any help would be greatly appreciated.


Private Sub cmdProcess_Click()
Set Rep = crxApplication.OpenReport(DENReportPath & "RPT335D.RPT", 1)

Rep.ReportTitle = Me.Caption

Rep.ReportComments = Rep.ReportComments & "Date Range: " _
& txtStartDate.text & " - " & txtEndDate.text

'build selection formula based on date range
D1 = SQLdate(txtStartDate.text) '*** Convert date to SQL format
D2 = SQLdate(txtEndDate.text)

SF = "{CCO_MST_DATE.MST_DATE} IN DATE(" & D1 & ") TO DATE(" & D2 & ")"
Comments = " All Departments All Items"

Rep.Database.LogOnServer "P2SODBC.DLL", "ATICTS" '*** Log into database
If Err Then
If Err <> &quot;-2147192184&quot; Then 'Cancel login
msg = &quot;Unable to establish connection, error = &quot; & Err & &quot; - &quot; & Err.Description
Call MsgBox(msg, StyleEx, ATICTS)
End If
Err.Clear
Hourglass False
Exit Sub
End If

Set RSFFile = d3Conn.brOpenFile(&quot;RSF&quot;) '*** Open Rpt Setup File -- List of Depts and emails

SF = Rep.RecordSelectionFormula '*** Set base formula, changes on dept

For X = 1 To RSFRec.brExtract(2).brDCount(VM) '*** Loop through departments
Dpt = RSFRec.brExtractStr(2, X) '*** Dept Number

Rep.RecordSelectionFormula = SF & &quot; and {CCO.MST_DEPT_ALL} = '&quot; _
& Dpt & &quot;'&quot; '*** Add dept as part of selection

Rep.ExportOptions.DestinationType = crEDTEMailMAPI
Rep.ExportOptions.FormatType = crEFTExactRichText
Rep.ExportOptions.MailSubject = &quot;Consumable Usage Report By Date Range&quot;
Rep.ExportOptions.MailMessage = &quot;For Department: &quot; & Dpt

ToString = RSFRec.brExtractStr(3, X) '*** Dept Head to email
CCString = RSFRec.brExtractStr(4, X) '*** Send CC to this person

MainEmail = &quot;&quot;
CCMail = &quot;&quot;

MainEmail = ToString
CCMail = CCString

Rep.ExportOptions.MailToList = &quot;&quot; '*** Clear out previous recipients
Rep.ExportOptions.MailToList = MainEmail
Rep.ExportOptions.MailCcList = CCMail

If Rep.ExportOptions.MailToList <> &quot;&quot; Then '*** Only export if email address
Rep.Export (False) '**** This is where the error is occuring ****
End If
Next X
 
I have the same problem. I'm trying to export report to the richtext file (.FormatType = crEFTExactRichText). All other formats work (.txt; .doc, etc).
My error occurs at the same place as yours. Maybe that's format issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top