我接近於語法準確,只是一個大問題!
,我從輸入框中捕獲用戶ID,沒有被傳遞到報告,所以我必須要輸入用戶ID兩次
訪問VBA將參數傳遞給基於查詢的報表
需要什麼,以實現這一目標被改變?
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'](https://msdn.microsoft.com/en-us/library/office/gg251648.aspx)一起使用,您可能的意思是使用'Exit Function' 。 – ThunderFrame
@ThunderFrame - 很好地捕捉到這種語法錯誤。 –