水晶报告错误:选择“此处需要一个字符串”

时间:2012-11-09 17:40:12

标签: crystal-reports

我在水晶报告中运行以下代码,它告诉我

  

“这里需要字符串”

关于第二个案件。我已经尝试将{?Pm-Student_course_attendance_csv.Level}作为字符串进行投射,但没有运气

 Global NumberVar grade;
 Global NumberVar baseline;

Select ({?Pm-Student_course_attendance_csv.Level})
  Case "R", "TL", "TU", "OTH", "P", "BTECFS": 
    If (CStr({PM_csv.mv_value}) = "Pass") Then
       "On Track"
    Else
       "Below"

  Case "H", "ASD", "AD", "AS", "G":     //error from this line onwards inclusive
     Select (CStr({PM_csv.mv_value}))
        Case "A*":
            grade := 11
        Case "A*/A":
            grade := 10
        Case "A":
            grade := 9
        Case "A/B":
            grade := 8
        Case "B":
            grade := 7
        Case "B/C":
            grade := 6
        Case "C":
            grade := 5
        Case "C/D":
            grade := 4
        Case "D":
            grade := 3
        Case "D/E":
            grade := 2
        Case "E":
            grade := 1
        Case "U":
            grade := 0
        Default :
            grade := 0;

1 个答案:

答案 0 :(得分:2)

您的公式不能有两种不同的返回类型。从错误及以上它返回一个字符串,但在它下面你试图返回一个数字(公式的返回类型也是最后一个赋值,所以如果你的公式做的最后一件事是grade:=1那么公式试图返回值1,它显然不允许你这样做。你必须在公式的后半部分为每个案例添加一个字符串返回值。

...
  Case "H", "ASD", "AD", "AS", "G":     //error from this line onwards inclusive
     Select (CStr({PM_csv.mv_value}))
        Case "A*":
            grade := 11;
            "Return value" //<---- Must be a string
        Case "A*/A":
...