我需要导出一个具有顺序名称的PDF文件:
“年”+“月”+“日”+“每日打印报表”
示例: 20200130_035
我写了日期代码。
Dim strArquivo As String
Dim strLocal As String
strArquivo = "" & Year(Date) & Month(Date) & Day(Date) & HERE THE REPORTS PRINTED QUANTITY & " .pdf "
strLocal = CurrentProject.Path & "\PDF\" & strArquivo
DoCmd.OutputTo acReport, "Report", acFormatPDF, strLocal我如何编写一个代码来计算每天打印的报告数量?
发布于 2020-02-01 00:05:25
马修斯
我已经把一些看起来可以工作的代码和一些注释放在一起。
我建议您将日期格式设置为一致的长度(例如"ddmmyy“或"yymmdd"),否则1月11日和11月1日都将显示为"111";
我还建议对报告编号进行分隔和格式化,例如"-001"/"-002“,以使内容更清晰;
在PDF报告时,您可能还希望存储报告名称。
Dim strLocal As String
Dim intCount As Integer
strLocal = Format(Date, "yymmdd")
intCount = Nz(DCount("PrintDate", "tblPrintID", "PrintDate='" & Format(Date, "yymmdd") & "'"), 0) + 1
strLocal = "C:\test\" & strLocal & "-" & Format(intCount,"000") & ".pdf"
Debug.Print strLocal
DoCmd.OutputTo acOutputReport, "rpt1", acFormatPDF, strLocal
CurrentDb.Execute "INSERT INTO tblPrintID (PrintDate,PrintReport) SELECT '" & Format(Date, "yymmdd") & "','rpt1';"问候
https://stackoverflow.com/questions/60004331
复制相似问题