简体   繁体   English

Crystal Reports 中的“无效对象格式名称”

[英]“Invalid Object Format Name” in Crystal Reports

When working with Crystal Report Field Objects and attempting to set "EnableSuppress" to False or alter the position or width of a field object is generating an "Invalid Object Format Name" error.使用 Crystal Report 字段对象并尝试将“EnableSuppress”设置为 False 或更改字段对象的位置或宽度时,会生成“无效对象格式名称”错误。 The debugger shows all my code running without error until attempting to actually load the report.调试器显示我的所有代码都在无错误地运行,直到尝试实际加载报告。 At that point, it will run the first couple without problem, then it fails when messing with a field object, and none of the rest will run.那时,它将毫无问题地运行第一对,然后在处理字段对象时失败,其余的都不会运行。 The code is shown below.代码如下所示。 Everything that generates an error is a FieldObject, but not all fieldObjects generate errors.生成错误的所有内容都是 FieldObject,但并非所有 fieldObject 都会生成错误。 In the code below, everything in Section2 is a TextObject and everything in Section3 is a 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

Unless you figure out what is different about the fields that throw errors and are absolutely set on formatting in VB code, I suggest that you do your formatting from within the Crystal report.除非您弄清楚在 VB 代码中引发错误和绝对设置格式的字段有何不同,否则我建议您在 Crystal 报表中进行格式设置。 You obviously know about the conditional suppression and to change size and location of a field you can right-clicking on the field and clicking "Size and Position".您显然知道条件抑制并更改字段的大小和位置,您可以右键单击该字段并单击“大小和位置”。 There is also an option for conditional placement (formula).还有一个条件放置选项(公式)。

Hope that helps,希望有所帮助,

Chris克里斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM