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) & "," & Month(Date - 1) & "," & Day(Date - 1)
Text2 = Year(Date - 1) & "," & Month(Date - 1) & "," & Day(Date - 1)
Else
Text1 = Year(Date - 3) & "," & Month(Date - 3) & "," & Day(Date - 3)
Text2 = Year(Date - 3) & "," & Month(Date - 3) & "," & Day(Date - 3)
End If
Screen.MousePointer = vbHourglass
Command1_Click
With Report.ExportOptions
.DestinationType = crEDTDiskFile
'.MailToList = "montejo, javier"
'.MailSubject = "Here's the fgparts of " & Date
'.MailMessage = "Attached is a excel document with the latest fgparts report"
.FormatType = crEFTExcel80Tabular
.ExcelTabHasColumnHeadings = True
.ExcelUseWorksheetFunctions = False
.ExcelUseTabularFormat = False
.ExcelAreaType = crGroupFooter
.DiskFileName = App.Path & "\4.xls"
End With
Report.Export False
Screen.MousePointer = vbDefault
javier:
Select Case Err.Number
Case -2147190908
MsgBox "adios", vbOKOnly
Err.Clear
End
Case 0
Err.Clear
End
Case Else
MsgBox "error " & Err.Number & " - " & Err.Description, vbCritical
Err.Clear
End
End Select
End Sub
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) & "," & Month(Date - 1) & "," & Day(Date - 1)
Text2 = Year(Date - 1) & "," & Month(Date - 1) & "," & Day(Date - 1)
Else
Text1 = Year(Date - 3) & "," & Month(Date - 3) & "," & Day(Date - 3)
Text2 = Year(Date - 3) & "," & Month(Date - 3) & "," & Day(Date - 3)
End If
Screen.MousePointer = vbHourglass
Command1_Click
With Report.ExportOptions
.DestinationType = crEDTDiskFile
'.MailToList = "montejo, javier"
'.MailSubject = "Here's the fgparts of " & Date
'.MailMessage = "Attached is a excel document with the latest fgparts report"
.FormatType = crEFTExcel80Tabular
.ExcelTabHasColumnHeadings = True
.ExcelUseWorksheetFunctions = False
.ExcelUseTabularFormat = False
.ExcelAreaType = crGroupFooter
.DiskFileName = App.Path & "\4.xls"
End With
Report.Export False
Screen.MousePointer = vbDefault
javier:
Select Case Err.Number
Case -2147190908
MsgBox "adios", vbOKOnly
Err.Clear
End
Case 0
Err.Clear
End
Case Else
MsgBox "error " & Err.Number & " - " & Err.Description, vbCritical
Err.Clear
End
End Select
End Sub