我怎么可以输出PDF格式的报告格式,那里的名称包含的价值从领域?
题
我想添加一些功能为我的访问,2007年报告由此PDF格式复制的该报告创建一个按钮。我知道有一个 OutputTo
宏它可以为我做的,但它并不允许我向包括报告领域的价值观的一部分的PDF格式的文件,即:
[Client Organisations].Code + "-" + Clients.Code + "-" + Invoices_Code + "-" + Format([Invoice Date],"yyyy") + ".pdf"
虽然我已经见过这个 MSDN线 和这个 所以问题, 我看不到所使用的场价值观在任何答复。
我认为载>>>情绪的路要走,因此我(不成功地)试图如下:
Private Sub Create_PDF_Click()
DoCmd.OutputTo acOutputReport, , acFormatPDF, "" + [Client Organisations].Code
+ "-" + Clients.Code + "-" + Invoices_Code + "-" + Format([Invoice Date],"yyyy")
+ ".pdf", True
End Sub
Run-time error'2465':
Microsoft Office的访问能不能找到该领域'|'中提到你的表情
任何想法,在那里?
解决方案
我得到了它的工作(最终).
下 sub
没有诀窍:
Private Sub Create_PDF_Click()
Dim myPath As String
Dim strReportName As String
DoCmd.OpenReport "Invoices", acViewPreview
myPath = "C:\Documents and Settings\"
strReportName = Report_Invoices.[Client Organisations_Code] + "-" +
Report_Invoices.Clients_Code + "-" + Report_Invoices.Invoices_Code + "-" +
Format(Report_Invoices.[Invoice Date], "yyyy") + ".pdf"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, True
DoCmd.Close acReport, "Invoices"
End Sub
两个告诫:
- 该报告需要开之前印刷。
- 请参阅领域通过的相同的姓名,该报告看到的那样。那
[Client Organisations].Code
是[Client Organisations_Code]
在本报告中。
其他提示
它更容易变暗的字符串,并把你的整个表达式那里,然后调试它,看它是否包含有效的报告名称。
像这样:
Dim strReportName as String
strReportName = [Client Organisations].Code
+ "-" + Clients.Code + "-" + Invoices_Code + "-" + Format([Invoice Date],"yyyy")
+ ".pdf"
//then try to print strReportName before you use DoCmd.OutputTo.
不隶属于 StackOverflow