2012-04-27 184 views
2

我编写了这段代码,但它有这个错误。将参数传递给水晶报告

“运行时错误‘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 

回答

0

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

.ParameterFields(n).AddCurrentValue "PARAMETER" 
0

尝试......

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
CR.ParameterFields.Item(1).AddCurrentValue "YourValue"