【发布时间】:2016-12-27 22:23:07
【问题描述】:
我接近语法准确,只是一个大问题!
我从输入框中捕获的用户 ID 没有被传递到报告中,所以我必须输入用户 ID两次
为了达到这个目的需要改变什么?
Public Function userProd() As Integer
Dim userID As String, saveloc As String, filename As String, reportname As String
'Report Name
reportname = "rpt_UserProduction"
'Setting Save location
saveloc = "C:\Test\"
'Setting filename
filename = "userProd "
'Getting User ID To Process
userID = InputBox("Enter User ID:", "VBA InputBox Function")
'Putting together full save location
saveloc = saveloc + filename + userID + ".pdf"
If userID = "" Then
'Do Nothing and Stop Processing
Exit Function
Else
If IsNumeric(userID) Then
'Preview Report
DoCmd.OpenReport reportname, acViewPreview, , "User_ID=" & userID
'Save As PDF
DoCmd.OutputTo acOutputReport, reportname, acFormatPDF, saveloc, True
'Close Report
DoCmd.Close acReport, reportname
End If
End If
End Function
【问题讨论】:
-
Return语句与GoSub一起使用,您可能的意思是使用Exit Function。 -
@ThunderFrame - 很好地抓住了那个语法错误。
标签: ms-access vba report ms-access-2013