2012-04-27 183 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"