【发布时间】:2013-10-23 15:06:02
【问题描述】:
使用 Crystal Report 字段对象并尝试将“EnableSuppress”设置为 False 或更改字段对象的位置或宽度时,会生成“无效的对象格式名称”错误。在尝试实际加载报告之前,调试器会显示我的所有代码都在正常运行。到那时,它将毫无问题地运行第一对,然后在与字段对象混淆时失败,其余的都不会运行。代码如下所示。产生错误的一切都是 FieldObject,但并非所有 fieldObject 都会产生错误。在下面的代码中,Section2 中的所有内容都是 TextObject,Section3 中的所有内容都是 FieldObject。
If condition = True Then
'Lines marked as runs ok, only run when a line that generates an error is not present before it.
Report.Section2.ReportObjects("Text7").Left = 7830 'Runs ok
Report.Section3.ReportObjects("Field4").Left = 8085 'Runs ok
Report.Section2.ReportObjects("Text13").ObjectFormat.EnableSuppress = False 'Runs ok
Report.Section3.ReportObjects("Field28").ObjectFormat.EnableSuppress = False 'error
Report.Section2.ReportObjects("Text9").Left = 10830 'Runs ok
Report.Section3.ReportObjects("Field23").Left = 10830 'error
Report.Section3.ReportObjects("Field23").Width = 615 'error
Report.Section2.ReportObjects("Text10").Left = 11445 'Runs ok
Report.Section3.ReportObjects("Field25").Left = 11445 'Runs ok
End If
【问题讨论】:
-
您是否尝试过使用公式隐藏 Crystal Report 中的字段?
-
我可以在 Crystal Report 中隐藏,但这无助于我移动和更改 Field23 的宽度(在我发布的代码中)。
-
您是否为 Field23 尝试过不同的值?测试看看是不是和值冲突(可能和Field25使用相同的值)还是字段本身冲突。
-
这似乎有效。 Field25 是一个数字 (Int),而 Field23 只是文本(从数据库中提取)。那会有什么不同吗?
-
不应该。 Field25 是否来自数据库?其他引发错误的字段呢?