我试图在我们使用的现有表单上编辑表达式。有问题的字段目前只有一个简单的= SWITCH表达式。我想添加一个嵌套在SWITCH或其他任何方式的附加表达式,它将检查来自同一DataSet1的附加字段值,并根据现有文本下面的商品打印出额外的T.O.S信息。目前,表达式如下所示:
=SWITCH(First(Fields!Origin_country, "DataSet1") = "USA",
"***PRINTS US VERSION OF TERMS OF SERVICE AGREEMENT***"
& vbCrLf &
"More text goes here...",
--Need to add nested expression to check a different field value from dataset 1.
First(Fields!Origin_Country, "DataSet1") = "CAN",
"***PRINTS CDN VERSION OF T.O.S***"
& vbCrLf &
"More text goes here..."
--Need to add nested expression to check a different field value from dataset 1.
) -- Closing bracket from =SWITCH
我尝试在现有= Switch中添加额外的Field值,但是我收到错误: "段落[0] .TextRuns [0]'包含错误:[BC30201]预期的表达式。" 尝试在= SWITCH中添加一个IIF语句,但我得到了这个错误: "文本框'textbox28'的值表达式直接指向字段'cmd_code',而不指定数据集聚合。当报表包含多个数据集时,数据区域外的字段引用必须包含在指定数据集范围的聚合函数中。 "
我想检查的字段值包括9个商品代码,我可以将其减少为2,如LIKE" PRO *"和LIKE" SEAFOO *" (生产和海鲜)。它们都属于农产品,因此它们都会在现有的T.O.S下面打印出相同的True结果; 1与美国T.O.S和其他加拿大人......
谢谢!
答案 0 :(得分:1)
从This我可以看出你的代码中有太多逗号。
=SWITCH(First(Fields!Origin_country, "DataSet1") = "USA",
"***PRINTS US VERSION OF TERMS OF SERVICE AGREEMENT***",
& vbCrLf &
"More text goes here...",
应该在哪里
=SWITCH(First(Fields!Origin_country, "DataSet1") = "USA",
"***PRINTS US VERSION OF TERMS OF SERVICE AGREEMENT***" (take this comma off)
& vbCrLf &
"More text goes here...",
First(Fields!Origin_Country, "DataSet1") = "CAN",
"***PRINTS CDN VERSION OF T.O.S***" (Take Comma Off)
& vbCrLf &
"More text goes here..."
另一个选项也是设置字符串以在sql查询中打印服务条款并将其拉入数据集中,以便您可以说
IIF First(Fields!Origin_Country, "DataSet1") = "CAN", Fields!USATOS.Value...
答案 1 :(得分:0)
所以我不是那么遥远,而且新家伙指出它可能只是一个错位的逗号,它就是(在IIF声明之前有一个逗号)
Expression现在看起来像这样,并且有效。文本字段位置有轻微问题,但我通过仅移动边距几个像素来修复它。
=SWITCH(First(Fields!Origin_country, "DataSet1") like "USA",
"***USA Version of TOS****"
& vbCrLf & "More text Here"
&vbCrLf & /*Had a comma on this line i had to remove... */
IIF(First(Fields!cmd_code.value, "DataSet1") like "PRO*", "USA PRODUCE TEXT",
IIF(First(Fields!cmd_code.value, "DataSet1") like "SEAFOO*", "USA PRODUCE TEXT", " " )
),
First(Fields!Origin_country, "DataSet1") like "CAN",
"***CANADIAN Version of TOS****"
& vbCrLf & "More text Here"
&vbCrLf &
IIF(First(Fields!cmd_code.value, "DataSet1") like "PRO*", "CDN PRODUCE TEXT",
IIF(First(Fields!cmd_code.value, "DataSet1") like "SEAFOO*", "CDN PRODUCE TEXT", " " )
)
)