Crystal Report Parameters - Date

G

Guest

I'm trying to run a report using a form containing a crystal report viewer, but I keep getting an error saying tha
"The specified value type is different to the current value type
I'm trying to use date parameters. The parameter is set up as a date in the report
Here's the code

Dim paramfields As New CrystalDecisions.Shared.ParameterField
Dim discreteval As New CrystalDecisions.Shared.ParameterDiscreteValu
Dim reporter As New bdb.frmReportViewe
Dim report As CrystalDecisions.CrystalReports.Engine.ReportDocumen
report = Nothin
report = New DetForAcc
reporter.ReportFileName = repor

Dim paramfield2 As New CrystalDecisions.Shared.ParameterFiel
paramfield2.ParameterValueKind = CrystalDecisions.[Shared].ParameterValueKind.DateParamete
paramfield2.ParameterFieldName = "EffectiveLow
discreteval.Value = dtpStart.Value.Dat
paramfield2.CurrentValues.Add(discreteval
paramfields.Add(paramfield2

reporter.ReportParameters = paramfield
reporter.MdiParent = Me.MdiParen
reporter.Show(

Any ideas
Thanks, Matt
 
B

Bernie Yaeger

Hi Matt,

This is a lousy answer, but I ran into the same problem and developed a
workaround: when the date was merely for display (eg, date due) I pass a
string to a string parameter. However, when it is needed in a selection
formula, I pass a selection formula something like this:
Dim mglobals As New globals

mglobals.gl_selectionstring = "{bnlsum.invnum} >= '" & startnumbox.Text &
Chr(39) & " and {bnlsum.invnum} <= '" & endnumbox.Text & Chr(39)

gl_browseprintvar = "f:\imcapps\bnlinv.rpt"

Dim newmdichild As New reportprinter_viewerparam

newmdichild.Text = "BNL Summary Invoice"

newmdichild.ShowDialog()

CrystalReportViewer1.SelectionFormula = mglobals.gl_selectionstring

Note that I use the crystal syntax for {bnlsum.invnum} etc, so the report
acknowledges the selection formula.

This works fine for defining a date range filter. I've luckily not run into
a situation that could not be thus solved.

HTH,

Bernie Yaeger



I'm trying to run a report using a form containing a crystal report
viewer, but I keep getting an error saying that
"The specified value type is different to the current value type"
I'm trying to use date parameters. The parameter is set up as a date in the report.
Here's the code.

Dim paramfields As New CrystalDecisions.Shared.ParameterFields
Dim discreteval As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim reporter As New bdb.frmReportViewer
Dim report As CrystalDecisions.CrystalReports.Engine.ReportDocument
report = Nothing
report = New DetForAcct
reporter.ReportFileName = report

Dim paramfield2 As New CrystalDecisions.Shared.ParameterField
paramfield2.ParameterValueKind = CrystalDecisions.[Shared].ParameterValueKind.DateParameter
paramfield2.ParameterFieldName = "EffectiveLow"
discreteval.Value = dtpStart.Value.Date
paramfield2.CurrentValues.Add(discreteval)
paramfields.Add(paramfield2)

reporter.ReportParameters = paramfields
reporter.MdiParent = Me.MdiParent
reporter.Show()

Any ideas?
Thanks, Matt
 
M

Matt MacDonald

Any idea how to go about it if I'm starting with a date data type from a
date time picker?

Bernie Yaeger said:
Hi Matt,

This is a lousy answer, but I ran into the same problem and developed a
workaround: when the date was merely for display (eg, date due) I pass a
string to a string parameter. However, when it is needed in a selection
formula, I pass a selection formula something like this:
Dim mglobals As New globals

mglobals.gl_selectionstring = "{bnlsum.invnum} >= '" & startnumbox.Text &
Chr(39) & " and {bnlsum.invnum} <= '" & endnumbox.Text & Chr(39)

gl_browseprintvar = "f:\imcapps\bnlinv.rpt"

Dim newmdichild As New reportprinter_viewerparam

newmdichild.Text = "BNL Summary Invoice"

newmdichild.ShowDialog()

CrystalReportViewer1.SelectionFormula = mglobals.gl_selectionstring

Note that I use the crystal syntax for {bnlsum.invnum} etc, so the report
acknowledges the selection formula.

This works fine for defining a date range filter. I've luckily not run into
a situation that could not be thus solved.

HTH,

Bernie Yaeger



I'm trying to run a report using a form containing a crystal report
viewer, but I keep getting an error saying that
"The specified value type is different to the current value type"
I'm trying to use date parameters. The parameter is set up as a date in the report.
Here's the code.

Dim paramfields As New CrystalDecisions.Shared.ParameterFields
Dim discreteval As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim reporter As New bdb.frmReportViewer
Dim report As CrystalDecisions.CrystalReports.Engine.ReportDocument
report = Nothing
report = New DetForAcct
reporter.ReportFileName = report

Dim paramfield2 As New CrystalDecisions.Shared.ParameterField
paramfield2.ParameterValueKind = CrystalDecisions.[Shared].ParameterValueKind.DateParameter
paramfield2.ParameterFieldName = "EffectiveLow"
discreteval.Value = dtpStart.Value.Date
paramfield2.CurrentValues.Add(discreteval)
paramfields.Add(paramfield2)

reporter.ReportParameters = paramfields
reporter.MdiParent = Me.MdiParent
reporter.Show()

Any ideas?
Thanks, Matt
 
B

Bernie Yaeger

Hi Matt,

Sure:

Dim d As String

d = DateTimePicker1.Value.ToShortDateString

MessageBox.Show(d)

d is now a string displaying, eg, 4/28/04. It's easy from here.

HTH,

Bernie



Matt MacDonald said:
Any idea how to go about it if I'm starting with a date data type from a
date time picker?

Bernie Yaeger said:
Hi Matt,

This is a lousy answer, but I ran into the same problem and developed a
workaround: when the date was merely for display (eg, date due) I pass a
string to a string parameter. However, when it is needed in a selection
formula, I pass a selection formula something like this:
Dim mglobals As New globals

mglobals.gl_selectionstring = "{bnlsum.invnum} >= '" & startnumbox.Text &
Chr(39) & " and {bnlsum.invnum} <= '" & endnumbox.Text & Chr(39)

gl_browseprintvar = "f:\imcapps\bnlinv.rpt"

Dim newmdichild As New reportprinter_viewerparam

newmdichild.Text = "BNL Summary Invoice"

newmdichild.ShowDialog()

CrystalReportViewer1.SelectionFormula = mglobals.gl_selectionstring

Note that I use the crystal syntax for {bnlsum.invnum} etc, so the report
acknowledges the selection formula.

This works fine for defining a date range filter. I've luckily not run into
a situation that could not be thus solved.

HTH,

Bernie Yaeger



I'm trying to run a report using a form containing a crystal report
viewer, but I keep getting an error saying that
"The specified value type is different to the current value type"
I'm trying to use date parameters. The parameter is set up as a date
in
the report.
Here's the code.

Dim paramfields As New CrystalDecisions.Shared.ParameterFields
Dim discreteval As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim reporter As New bdb.frmReportViewer
Dim report As CrystalDecisions.CrystalReports.Engine.ReportDocument
report = Nothing
report = New DetForAcct
reporter.ReportFileName = report

Dim paramfield2 As New CrystalDecisions.Shared.ParameterField
paramfield2.ParameterValueKind = CrystalDecisions.[Shared].ParameterValueKind.DateParameter
paramfield2.ParameterFieldName = "EffectiveLow"
discreteval.Value = dtpStart.Value.Date
paramfield2.CurrentValues.Add(discreteval)
paramfields.Add(paramfield2)

reporter.ReportParameters = paramfields
reporter.MdiParent = Me.MdiParent
reporter.Show()

Any ideas?
Thanks, Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top