Passing Parameters to Crystal Report at Runtime
-
Hello I have to pass parameters to crystal report at runtime,i have already created reports in crystal report 9,below is my code Dim reportdocument As New ReportDocument Dim strRptPath As String strRptPath = "d:\Attendance System\Attendance Reports\TodayAbsRpt.rpt" reportdocument.Load(strRptPath) Dim paramdefs As ParameterFieldDefinitions Dim paramdef As ParameterFieldDefinition Dim paramvalues As New ParameterValues Dim paramdisval As New ParameterDiscreteValue Dim todayval As Long todayval = Me.DTPsdate.Text.Substring(6, 4) & Mid(Me.DTPsdate.Text, 4, 2) & Me.DTPsdate.Text.Substring(0, 2) paramdefs = reportdocument.DataDefinition.ParameterFields For Each paramdef In paramdefs With paramdef Select Case .ParameterFieldName Case "DpttNm" paramdisval.Value = "'" & Me.cmbDptt.Text & "'" paramvalues.Add(paramdisval) paramdef.ApplyCurrentValues(paramvalues) Case "pDate" paramdisval.Value = todayval paramvalues.Add(paramdisval) paramdef.ApplyCurrentValues(paramvalues) End Select End With Next Dim frm As New FrmRpt frm.crViewer1.reportSource=reportdocument frm.Show() the crystal report viewet is on another form ....the problem is that the crystal report viewer doe'snt load the report please help me ur corporation is highly appreciated thanks
-
Hello I have to pass parameters to crystal report at runtime,i have already created reports in crystal report 9,below is my code Dim reportdocument As New ReportDocument Dim strRptPath As String strRptPath = "d:\Attendance System\Attendance Reports\TodayAbsRpt.rpt" reportdocument.Load(strRptPath) Dim paramdefs As ParameterFieldDefinitions Dim paramdef As ParameterFieldDefinition Dim paramvalues As New ParameterValues Dim paramdisval As New ParameterDiscreteValue Dim todayval As Long todayval = Me.DTPsdate.Text.Substring(6, 4) & Mid(Me.DTPsdate.Text, 4, 2) & Me.DTPsdate.Text.Substring(0, 2) paramdefs = reportdocument.DataDefinition.ParameterFields For Each paramdef In paramdefs With paramdef Select Case .ParameterFieldName Case "DpttNm" paramdisval.Value = "'" & Me.cmbDptt.Text & "'" paramvalues.Add(paramdisval) paramdef.ApplyCurrentValues(paramvalues) Case "pDate" paramdisval.Value = todayval paramvalues.Add(paramdisval) paramdef.ApplyCurrentValues(paramvalues) End Select End With Next Dim frm As New FrmRpt frm.crViewer1.reportSource=reportdocument frm.Show() the crystal report viewet is on another form ....the problem is that the crystal report viewer doe'snt load the report please help me ur corporation is highly appreciated thanks
Please add a single line after the following Line: frm.crViewer1.reportSource=reportdocument; crViewer1.Show(); frm.Show();