[英]“Invalid Object Format Name” in Crystal Reports
使用 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
除非您弄清楚在 VB 代碼中引發錯誤和絕對設置格式的字段有何不同,否則我建議您在 Crystal 報表中進行格式設置。 您顯然知道條件抑制並更改字段的大小和位置,您可以右鍵單擊該字段並單擊“大小和位置”。 還有一個條件放置選項(公式)。
希望有所幫助,
克里斯
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.