MS Access 365
Hello everyone, thank you for your past help.
I've now got a little problem trying to save a report in a specified folder.
I've followed all the example I could find on the net, but it just won't work for me!
I'm obviously doing something fundamentally wrong, but I just can't nail it.
Your help would be appreciated.
I get this error message:
"Run-time error 2498
The expression you entered is the wrong data type for one of the arguments."
----------------------
When I use this code, everything works fine and the file (in PDF Format) is saved to the Documents Folder.
Private Sub Save_PDF_Button_Click()
Dim strReport As String
Dim strWhere As String
Dim strFileName As String
Dim strSaveName As String
strSaveName = Replace(Me.First_Name, "*", "")
strReport = "Rel_View_Data_Rpt"
strWhere = "[ID]=" & Me!ID
strFileName = strSaveName & " " & Me.Last_Name & ".pdf"
DoCmd.OpenReport strReport, acViewPreview, , strWhere, acWindowNormal
DoCmd.OutputTo acOutputReport, strReport, acFormatPDF, strFileName, False
DoCmd.Close acReport, strReport
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."
End Sub
----------------------------------------------------------------------
However, when I use the same code and add the folder I want the file save to, I get the "2498" error!
Where am I going wrong, please.
(I've highlighted what I added in RED)
Private Sub Save_PDF_Button_Click()
Dim strReport As String
Dim strWhere As String
Dim strFileName As String
Dim strSaveName As String
Dim strFolder as String
strFolder = "C:\Personal_DB_PDF_Files\"
strSaveName = Replace(Me.First_Name, "*", "")
strReport = "Rel_View_Data_Rpt"
strWhere = "[ID]=" & Me!ID
strFileName = strSaveName & " " & Me.Last_Name & ".pdf"
DoCmd.OpenReport strReport, acViewPreview, , strWhere, acWindowNormal
DoCmd.OutputTo acOutputReport, strReport, acFormatPDF, strFileName, strFolder, False
DoCmd.Close acReport, strReport
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."
End Sub
Hello everyone, thank you for your past help.
I've now got a little problem trying to save a report in a specified folder.
I've followed all the example I could find on the net, but it just won't work for me!
I'm obviously doing something fundamentally wrong, but I just can't nail it.
Your help would be appreciated.
I get this error message:
"Run-time error 2498
The expression you entered is the wrong data type for one of the arguments."
----------------------
When I use this code, everything works fine and the file (in PDF Format) is saved to the Documents Folder.
Private Sub Save_PDF_Button_Click()
Dim strReport As String
Dim strWhere As String
Dim strFileName As String
Dim strSaveName As String
strSaveName = Replace(Me.First_Name, "*", "")
strReport = "Rel_View_Data_Rpt"
strWhere = "[ID]=" & Me!ID
strFileName = strSaveName & " " & Me.Last_Name & ".pdf"
DoCmd.OpenReport strReport, acViewPreview, , strWhere, acWindowNormal
DoCmd.OutputTo acOutputReport, strReport, acFormatPDF, strFileName, False
DoCmd.Close acReport, strReport
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."
End Sub
----------------------------------------------------------------------
However, when I use the same code and add the folder I want the file save to, I get the "2498" error!
Where am I going wrong, please.
(I've highlighted what I added in RED)
Private Sub Save_PDF_Button_Click()
Dim strReport As String
Dim strWhere As String
Dim strFileName As String
Dim strSaveName As String
Dim strFolder as String
strFolder = "C:\Personal_DB_PDF_Files\"
strSaveName = Replace(Me.First_Name, "*", "")
strReport = "Rel_View_Data_Rpt"
strWhere = "[ID]=" & Me!ID
strFileName = strSaveName & " " & Me.Last_Name & ".pdf"
DoCmd.OpenReport strReport, acViewPreview, , strWhere, acWindowNormal
DoCmd.OutputTo acOutputReport, strReport, acFormatPDF, strFileName, strFolder, False
DoCmd.Close acReport, strReport
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."
End Sub