将参数传递给水晶报告

时间:2012-04-27 07:14:40

标签: vb6 crystal-reports

我编写此代码但它有此错误。

  

“运行时错误'20553':参数字段名称无效”

任何人都可以帮我解决吗?

With CR

  .ParameterFields(0) = "start;" + CStr(Form1.cmbMonth.Text) & ";True"
  .ParameterFields(1) = "end;" + CStr(Form1.cmbYear.Text) & ";True"

  .ReportFileName = App.Path & "\Report\Report1.rpt"

  .SelectionFormula = "{SW.dtaMonth}>=date('" & Format(Form1.cmbMonth.Text) & "') and {SW.dtaYear}<=date(" & Format(Form1.cmbYear.Text) & ")"

  .WindowTitle = "PG Variable Overhead Report" 'title of report
  .Action = 1 'Will Show The Report

End With

3 个答案:

答案 0 :(得分:1)

试试这个......

With CR
  .ParameterFields(0) = "start;" & CStr(Form1.cmbMonth.Text) & ";True"
  .ParameterFields(1) = "end;" & CStr(Form1.cmbYear.Text) & ";True"
  .ReportFileName = App.Path & "\Report\Report1.rpt"
  .SelectionFormula = "{SW.dtaMonth}>=date('" & Format(Form1.cmbMonth.Text) & "') and {SW.dtaYear}<=date(" & Format(Form1.cmbYear.Text) & ")"
  .WindowTitle = "PG Variable Overhead Report" 'title of report   .Action = 1 'Will Show The Report
End With

答案 1 :(得分:0)

我认为Crystal在某些时候改变了参数传递给外部(非嵌入式)报告的方式,但我不确定他们使用哪个版本。我的版本是10,并使用此方法传递参数:

.ParameterFields(n).AddCurrentValue "PARAMETER"

答案 2 :(得分:-1)

 CR.ParameterFields.Item(1).AddCurrentValue "YourValue"