简体   繁体   English

访问标签报告中标签的数量和位置在打印预览中正确显示当前记录,但在打印或导出中不正确

[英]Number and position of labels in Access Labels Report on current record correct in Print Preview but not in Print or Export

I try to create a label report from sub-form on current record. 我尝试根据当前记录的子表单创建标签报告。 Bellow are basic Subs. 波纹管是基本的潜艇。

Code Behind form button 表单后面的代码按钮

Private Sub btnBlueLabels_Click()
Dim strWhere As String
Dim strDocName As String
strDocName = "rptBlueLabels"
strWhere = "AllocationAlphaName = """ & Me.frmSubAllocations.Form!AllocationAlphaName & """ AND AdvanceAllocationID = """ & Me.frmSubAllocations.Form!AdvanceAllocationID & """"
If IsNull(Me.frmSubAllocations.Form!AllocationLongName) Then
    MsgBox "No allocation records for this entity. The report will now close."
    Exit Sub
Else
    DoCmd.OpenReport strDocName, acViewPreview, , strWhere, acDialog

End If End Sub

Code behind Report 报告后的代码

 Sub BDetailOnFormat(rpt As Report)
'Print a specified number of blank detail sections.
If intSkipPosition <> 0 Then
        rpt.MoveLayout = True
        rpt.NextRecord = False
        rpt.PrintSection = False
        intSkipPosition = intSkipPosition - 1
    End If End Sub


Sub BDetailOnPrint(rpt As Report)
       If intCopiesCout < intCopies Then
        rpt.NextRecord = False
        intCopiesCout = intCopiesCout + 1

    End If
End Sub

In the Print Preview everything looks good. 在“打印预览”中,一切看起来都很不错。

in the picture: print preview pop up window - three of used labels skipped and three same labels needs to be printed 在图片中:打印预览弹出窗口-跳过三个使用的标签,并且需要打印三个相同的标签

When I try to print the Print Preview, it prints only one label (not three) and it located on the top and left position of a page. 当我尝试打印“打印预览”时,它仅打印一个标签(不是三个),并且位于页面的顶部和左侧。

Print output 打印输出

Please, I am asking for advice! 拜托,我在征求意见! Thank you. 谢谢。

Move the code that prompts input boxes to set the public variables into the form procedure before the OpenReport line instead of in the report Open procedure. 将提示输入框的代码移动到OpenReport行之前而不是报表Open过程中的表单过程中,以设置公共变量。 Declare the 3 variables in the module headers as Global and will be available to the form procedures. 将模块标题中的3个变量声明为Global,并将其提供给表单过程。 (My preference would be textboxes to input the Skip and Copies values then form code sets starting values for the global variables. Use textbox validation properties.) Do the validation in form so don't even call the report if inputs are not valid. (我的偏爱是在文本框中输入“跳过”和“副本”值,然后为全局变量设置代码集的起始值。使用文本框验证属性。)在窗体中进行验证,因此,如果输入无效,甚至不调用报表。 Actually, put this code into a Sub that can be called by both buttons. 实际上,将此代码放入可以由两个按钮调用的Sub中。 The code currently in the buttons could be consolidated into this Sub. 当前按钮中的代码可以合并到此Sub中。

This works going direct to printer. 这可以直接用于打印机。 But PrintPreview to printer does not because the report events do not run again. 但是,将PrintPreview发送给打印机不会因为报告事件不会再次运行。 This is an either/or situation - either to screen or to printer, can't do both. 这是一种/或一种情况-屏幕还是打印机,都不能做到。

Whether to screen or printer, report recordset is properly filtered. 无论是丝网印刷还是打印机印刷,报告记录集均已正确过滤。

Other Notes: 其他说明:

Missing Option Explicit in several modules. 缺少Option Explicit在多个模块中Option Explicit

BlueLabels and WhiteLabels modules are virtually indentical. BlueLabels和WhiteLabels模块实际上是相同的。 Why not 1 generic module? 为什么不使用1个通用模块? They are not showing in Navigation Pane. 它们没有显示在导航窗格中。 Had to create new module (consolidated) and delete the old ones. 必须创建(合并)新模块并删除旧模块。

WhiteLabels Sub WDetailOnPrint procedure is missing the On Error statement. WhiteLabels Sub WDetailOnPrint过程缺少On Error语句。

The Exit Sub line in the If Then structures is not necessary. If Then结构中的Exit Sub行不是必需的。 In fact, prevents execution of the Exit_Procedure: code. 实际上,阻止执行Exit_Procedure:代码。 This code has Set Warnings True . 该代码Set Warnings True Why? 为什么? Warnings are never set false. 警告绝不会设置为假。

RedLabelSecond textbox shows 'invalid control source' error, had to reselect the field to clear that. RedLabelSecond文本框显示“无效的控制源”错误,必须重新选择该字段以清除该错误。

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

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