[英]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: 报告打印符合预期:
Form prints all records: 表格打印所有记录:
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 您可以通过避免
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.