Thank you in advance for your help!!!
Please look ???? ***** in code. I have two subreports that uses parameters entered on main report.
How can I assign the values to the subreport parameters? When I ran the crystal report within MSAccess, the subreports parameters do not automatically get assigned the values from the parameters from the main report as when I ran the report using Crystal reports.
Dim crxReport As New CRAXDRT.Report
Dim myParamField As CRAXDRT.ParameterFieldDefinition
Dim db As strSql, strFileName, strMsg As String
Dim strAttachDir, strAttachment, strReportDir, strCrReport As String
'Set db = CurrentDb
strAttachDir = "T:\Work\"
'open crystal report(rpt)
strReportDir = "T:\Work\"
strCrReport = "TimeDetailwithData.rpt"
Set crxReport = crxApplication.OpenReport(strReportDir & strCrReport)
strFileName = Format(Now(), "YYYY-MM-DD-HHMM") & "-TimeDetail.rpt"
strAttachment = strAttachDir & strFileName
crxReport.DiscardSavedData
'SET PARAMETER FIELDS
Set myParamFields = crxReport.ParameterFields
For Each myParamField In myParamFields
With myParamField
Select Case .ParameterFieldName
Case "StartPeriod"
.SetCurrentValue CDate("2008-7-16")
Case "EndPeriod"
.SetCurrentValue CDate("2008-7-17")
Case "Org - Comp"
.SetCurrentValue "2WV"
Case "Org - Dpt"
.SetCurrentValue "300"
Case "Org - Fac"
.SetCurrentValue "01302"
End Select
End With
Next
???? ***** Subreport1: Uses "StartPeriod" and "EndPeriod" as parameters from main report
???? ***** Subreport2: Uses "StartPeriod", "EndPeriod", "Org - Comp", "Org - Dpt", "Org - Fac"
as parameters from main report
crxReport.EnableParameterPrompting = False
crxReport.ExportOptions.FormatType = crEFTCrystalReport70
crxReport.ExportOptions.DestinationType = crEDTDiskFile
crxReport.ExportOptions.DiskFileName = strAttachment
crxReport.Export False
Set crxReport = crxApplication.OpenReport(strAttachment)
With Me!CRViewer
.ReportSource = crxReport
.ViewReport
.Zoom (95)
.EnablePrintButton = True
End With
While Me!CRViewer.IsBusy
DoEvents
Wend