【发布时间】:2016-03-31 16:55:17
【问题描述】:
我正在尝试在 Access 中使用以下代码将多个表单输出到 pdf 文件:
Public Function Print_Form()
Dim myPath, reportName As String
For Each r In gvParent_Vals
glParent_id = r
If giMsgBox = 1 Then
//this method opens the form and makes it the active object
Select_Form
//set file path and pdf file to send form to
myPath = "C:\Users\C062342\Desktop\"
reportName = "test.pdf"
//output page 1 of the form
DoCmd.OutputTo acOutputForm, "Frm_Main_Report", acFormatPDF, myPath & reportName, False
// set global variable to page 2 source form and specify target to replace (subform of page 1 form)
gsActiveForm = "Frm_Main_Report_Pg2"
Set goCurrForm = Forms![Frm_Main_Report].Form.[Frm_Main_Report_Pg1]
//method to set the page 2 form by setting the target equal to the new source object
Activate_Form
//send page 2 to the same pdf file
DoCmd.OutputTo acOutputForm, "Frm_Main_Report", acFormatPDF, myPath & reportName, False
//method to Close the form
Close_Form
End If
Next r
End Function
当我在循环中执行此操作时,我只会得到最后一个打开的表单,就好像当 Access 将每个表单发送到 PDF 文件时,它每次都会覆盖最后一个表单。另一个问题是我需要横向输出表单,但我不确定如何在 PDF 文件中发生这种情况。是否有任何与此方法或代码相关的设置可以在它之前或之后允许我完成此操作?
【问题讨论】: