構文が正確で、1つの大きな問題があります。入力に
私は入力ボックスからキャプチャしていますユーザー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 - その文法の間違いをよく理解する。 –