简体   繁体   English

访问报告-打印预览不会打印

[英]Access Report - Print Preview Won't Print

I have a macro that opens a report in print preview, with the current record displayed. 我有一个宏,可以在打印预览中打开报告,并显示当前记录。 The report pulls information from the same form that this print preview button is on. 该报告从与该打印预览按钮相同的表单中提取信息。

The problem is, sometimes the print button works and prints the single report record, other times it prints every single record in the form format. 问题是,有时“打印”按钮可以工作并打印单个报告记录,而其他时候它以表单格式打印每个单个记录。

Here is the code linked to a button in the form: 这是链接到表单中的按钮的代码:

Private Sub Print_Record_Click()
'Save and print record

On Error GoTo Err_Msg

CurrentDb.Execute "qryOrderQty", dbFailOnError
DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenReport "rptWorkOrder", acViewPreview, , "Prod_Num = " & Me!Prod_Num

Exit Sub

Err_Msg:
    MsgBox Err.Description

End Sub

Not sure if it helps, but here are some circumstances that I think lead to whether or not the error occurs. 不确定是否有帮助,但是我认为在某些情况下会导致错误发生。 We'll call the report and form above Report1 and Form1, respectively. 我们将分别在Report1和Form1上方调用报表和表单。

Report prints as expected: 报告打印符合预期:

  1. User opens database on front page 用户在首页上打开数据库
  2. Clicks button on front page to open Form1 and enters information 单击首页上的按钮以打开Form1并输入信息
  3. Clicks Print Preview button, activating macro above 单击“打印预览”按钮,激活上方的宏
  4. Clicks Print button in ribbon, Report1 prints single record 单击功能区中的“打印”按钮,Report1打印单个记录

Form prints all records: 表格打印所有记录:

  1. User opens database on front page 用户在首页上打开数据库
  2. Clicks button on front page to open Form2 and enters information 单击首页上的按钮以打开Form2并输入信息
  3. Clicks button on Form 2 to open Form1 and enters information 单击窗体2上的按钮以打开Form1并输入信息
  4. Clicks Print Preview button, activation macro above 单击“打印预览”按钮,上面的激活宏
  5. Clicks Print button in ribbon, Form1 prints ALL records 单击功能区中的“打印”按钮,Form1将打印所有记录

Since you write that all records are getting printed in form format, it seems quite obvious that 'Form1' has the focus when you press the print button on the ribbon. 由于您写道所有记录都是以表格格式打印的,因此当您按下功能区上的“打印”按钮时,“ Form1”便成为焦点。

You could avoid that by 您可以通过避免

  • Closing 'Form1' when opening the report 打开报表时关闭“ Form1”
  • Using the right click menu of the report to press the print button 使用报告的右键菜单按打印按钮
  • Creating a separate print button on 'Form1' that sends the report to the printer without previewing it 在“ Form1”上创建一个单独的打印按钮,将报告发送到打印机而不预览

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

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