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

exporting to excell a report with a subreport in footer from vb

Status
Not open for further replies.

yakko

Programmer
Apr 16, 2002
24
MX
I have a report with a subreport (unlinked) in the footer section.
I want to automate the exporting to excell. but i have some problems.
Any idea about how can I do this.

Thanks.

this is my code. it works for anothers reports with subreports but not mine.

Option Explicit

Private Sub Command1_Click()
Dim crxFormulaFields As CRAXDRT.FormulaFieldDefinitions
Dim crxFormulaField As CRAXDRT.FormulaFieldDefinition
Dim crpSubreport As CRAXDRT.Report

Set crxFormulaFields = Report.FormulaFields

For Each crxFormulaField In Report.FormulaFields
If crxFormulaField.FormulaFieldName = "date" Then
crxFormulaField.Text = "cdate(" & Text1 & ")"
Exit For
End If
Next


Set crpSubreport = Report.OpenSubreport("ediclau.rpt")
Set crxFormulaFields = crpSubreport.FormulaFields

For Each crxFormulaField In crpSubreport.FormulaFields
If crxFormulaField.FormulaFieldName = "d1" Then
crxFormulaField.Text = "cdate(" & Text2 & ")"
Exit For
End If
Next

End Sub



Private Sub Form_Load()
On Error GoTo javier

Dim fecha As Date

fecha = Weekday(Date, vbMonday)

If Date >= CDate("2002,4,28") Then
MsgBox "actualizar reporte", vbOKOnly
End
End If


If fecha <> 1 Then
Text1 = Year(Date - 1) & &quot;,&quot; & Month(Date - 1) & &quot;,&quot; & Day(Date - 1)
Text2 = Year(Date - 1) & &quot;,&quot; & Month(Date - 1) & &quot;,&quot; & Day(Date - 1)
Else
Text1 = Year(Date - 3) & &quot;,&quot; & Month(Date - 3) & &quot;,&quot; & Day(Date - 3)
Text2 = Year(Date - 3) & &quot;,&quot; & Month(Date - 3) & &quot;,&quot; & Day(Date - 3)
End If


Screen.MousePointer = vbHourglass
Command1_Click
With Report.ExportOptions
.DestinationType = crEDTDiskFile
'.MailToList = &quot;montejo, javier&quot;
'.MailSubject = &quot;Here's the fgparts of &quot; & Date
'.MailMessage = &quot;Attached is a excel document with the latest fgparts report&quot;
.FormatType = crEFTExcel80Tabular
.ExcelTabHasColumnHeadings = True
.ExcelUseWorksheetFunctions = False
.ExcelUseTabularFormat = False
.ExcelAreaType = crGroupFooter
.DiskFileName = App.Path & &quot;\4.xls&quot;
End With
Report.Export False
Screen.MousePointer = vbDefault

javier:

Select Case Err.Number
Case -2147190908
MsgBox &quot;adios&quot;, vbOKOnly
Err.Clear
End

Case 0
Err.Clear
End


Case Else
MsgBox &quot;error &quot; & Err.Number & &quot; - &quot; & Err.Description, vbCritical
Err.Clear
End
End Select

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top