因此,当我单击按钮时,它将打开具有正确文件名的保存对话框,并在预览模式下打开报告,但是当我单击保存时,它会给出错误代码。我见过其他人说这是因为没有声明对象。谁能帮我?如果我让它工作,它将节省我每个月手动输入文件名超过6小时!
Option Compare Database
'------------------------------------------------------------
' Export_MLR
'
'------------------------------------------------------------
Function Export_MLR()
On Error GoTo Export_MLR_Err
Dim strReportName As String
DoCmd.OpenReport "Market Rate Notification Final", acViewPreview
strReportName = Format(Reports![Market Rate Notification Final].Market_ID, "00") & " " & Reports![Market Rate Notification Final].Product_Code & "-" & "Market Rate Notification Final" & "_" & Format(Date, "mmddyy")
DoCmd.OutputTo acOutputReport, strReportName, "PDFFormat(*.pdf)", "", False, "", , acExportQualityScreen
Export_MLR_Exit:
Exit Function
Export_MLR_Err:
MsgBox Error$
Resume Export_MLR_Exit
End Function
答案 0 :(得分:0)
来自评论:
我想出了自己的错误:这是对DoCmd.Outputto的修复 line:
DoCmd.OutputTo acOutputReport, "Market Rate Notification Final",
"PDFFormat(*.pdf)", strReportName, False, , , acExportQualityScreen
- 尼克