2

因此,当我单击该按钮时,它将使用正确的文件名打开保存对话框,并在预览模式下打开报告,但是当我单击保存时,它会给我错误代码。我看到其他人说这是因为没有声明对象。谁能帮我?如果我让它工作,它将节省我每个月手动输入文件名超过 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
4

1 回答 1

0

来自评论:

我发现了自己的错误:这是 DoCmd.Outputto 行的修复:

DoCmd.OutputTo acOutputReport, "Market Rate Notification Final",
 "PDFFormat(*.pdf)", strReportName, False, , , acExportQualityScreen

– 尼克

于 2012-09-14T11:26:51.767 回答