我在报告中添加了VBA,在发票中包含空白行,从here获取此代码。打印预览显示我想要的空白行,但是当我想将其导出为PDF或打印报告时,它会显示隐形文本(而不是仅显示在空白行中)。我编辑了原始代码以重置增量编号,但这仅在从报表视图切换到打印预览时才有效(问题原因也在这里,我想在打印或导出时也会重新查询报表,因此问题将得到解决,但无济于事。)
这是给我空白行的代码:
Option Compare Database
Option Explicit
Const iLines As Integer = 15
Private iTotal As Integer
' code added to make count able to reset on report load
Private iLine As Integer
Private Sub Report_Open(Cancel As Integer)
' get total record count
iTotal = DCount("*", "OrderLine", "fkOrderID = " & TempVars!tempOrderID)
' code added to reset count
iLine = 0
End Sub
Private Sub Details_Format(Cancel As Integer, _
FormatCount As Integer)
' code added to reset visibility
Me!Item.Visible = True
Me!qty.Visible = True
Me!CalcPrijs.Visible = True
Me!TotPrijs.Visible = True
' increment iLine on each detail format
iLine = iLine + 1
If iLine < iTotal Then
' do nothing ... print as usual
ElseIf iLine = iTotal Then
' if there are more lines to print, set the
' NextRecord property to false, preventing
' the report from exiting prematurely
If iLine < iLines Then Me.NextRecord = False
Else
' changed this to make text invisible instead of white
Me!Item.Visible = False
Me!qty.Visible = False
Me!CalcPrijs.Visible = False
Me!TotPrijs.Visible = False
' prevent report from advancing past last row
' until all of blank lines has have printed
If iLine < iLines Then Me.NextRecord = False
End If
End Sub
我在这里遗漏了什么吗?我希望好看的打印预览会给我一个漂亮的打印输出。有没有办法可以获得额外的空行而不会丢失打印输出的数据?我添加了一些图片来澄清我想要的东西。
答案 0 :(得分:0)
找到解决方案。不得不拨打pageHeaderSection_Print
子
在报告格式化打印时重置iLine变量,现在一切都按照我想要的方式工作。