DoCmd.PrintOut仅打印一份副本

时间:2017-12-06 13:02:21

标签: vba ms-access

我看到有similar question作为我的,但是给出的解决方法对我来说是不可能的。 我必须打印1000或更多。

 DoCmd.OpenReport Report, acViewReport 'Open report
 DoCmd.PrintOut , , , acHigh, copys' Print report

(作为copys,我已经指定了副本的数量。)

我做错了吗?

还有其他方法可以打印报告吗?

感谢您的帮助。

完整代码:

Private Sub cmd_openreport_Click()

'Set Variables
Dim Report
Dim Etikette
Dim Copyes As String
Dim SQLString
Dim SQLString2


DoCmd.SetWarnings False 'Turns Off Warnings

Etikette = comb_etiketten_auswahl 'Etikette Equals the             comb_etiketten_auswahl value
Report = comb_etiketten_layout 'Report equals the value in the dropdown list
Copyes = Forms!frm_Hauptmenu!comb_etiketten_auswahl.Column(1)


'If The Etiketten Dropdown is empty message to client
If Etikette <> "" Then

'Do Nothing/Continue

Else
MsgBox "Bitte wählen Sie einen Datensatz aus"
Exit Sub

End If


'If The Report Dropdown is empty message to client
If Report <> "" Then

'Do Nothing (because dropdown is mot empty)

Else
MsgBox "Bitte wählen Sie ein Etikettenlayout aus"
Exit Sub

End If

MsgBox anzahl
'If Amount of copies is less than 1 message to client
If anzahl > 0 Then


On Error GoTo Error_MayCauseAnError
    DoCmd.OpenReport Report, acViewReport 'Open report
    DoCmd.PrintOut , , , , Copyes
    DoCmd.Close Report ' Close the Report

编辑:

这个问题是相关的,没有任何目的了! 这是一个内部脚本错误!

2 个答案:

答案 0 :(得分:0)

您是否将copyes声明为Variant?

阅读PrintOut文档,我发现了以下内容:

名称副本

必填/可选可选

数据类型变体

说明要打印的份数。如果将此参数留空,则假定为默认值(1)。

  

https://msdn.microsoft.com/en-us/vba/access-vba/articles/docmd-printout-method-access

此外,尝试使用值而不是仅用于测试的变量。

当您使用函数时,阅读函数文档非常重要,以了解此函数(或过程)所期望的变量类型。 在这种情况下,此函数使用Variant变量(不知道为什么),然后您应该提供Variant对象。 我举个例子。

你有一台饮料机。 让我们从变体的角度思考金钱。 papermetal。 你的饮料机只接受paper钱。如果您尝试插入metal(硬币),您的机器将出错。 在这种情况下,您需要提供饮料机所接受的特定款项。

希望这些说明能让您更好地理解问题并帮助您阅读所使用的功能或程序的文档。

答案 1 :(得分:0)

我不认为我明白为什么你有&#34;副本&#34;紧接着&#34; PrintOut&#34;。你想要的只是打印一定数量的副本,对吧?你可以简单地把

DoCmd.PrintOut , , , , copys 'Print report

或者,你也应该能够写

DoCmd.PrintOut Copies:=copys 'Print report

您不需要编写acHigh,因为这是默认值