Antony Cole
Registered User.
- Local time
- Yesterday, 18:54
- Joined
- Mar 14, 2012
- Messages
- 16
Hi,
Please can someone help me where i'm going wrong with the code below. I'm trying to output a report to PDF from a form and save it to the current windows logged on users profile in Teams, but I keep getting a runtime 2501 error the outputto action was cancelled. Thanks in advance
Private Sub Command115_Exit(Cancel As Integer)
Dim filename As String
Dim strUserName As String, strPath As String
Dim reportName As String
Dim Criteria As String
filename = Me.[Prepared By] & "-" & "GFM" & "" & Me.[Quote Ref] & "-" & Me.[Minor Works Title]
strUserName = Environ("username")
strPath = "C:\Users\& Strusername &\GRAHAM\GFM Team - Documents\Quotes" & filename & ".PDF"
reportName = "QuoteDetailsT1"
Criteria = "[Quote Ref] = " & Me.[Quote Ref]
DoCmd.OpenReport reportName, acViewPreview, , Criteria, acHidden
DoCmd.OutputTo acOutputReport, reportName, acFormatPDF, strPath, True
DoCmd.Close acReport, reportName, acSaveNo
End Sub
Please can someone help me where i'm going wrong with the code below. I'm trying to output a report to PDF from a form and save it to the current windows logged on users profile in Teams, but I keep getting a runtime 2501 error the outputto action was cancelled. Thanks in advance
Private Sub Command115_Exit(Cancel As Integer)
Dim filename As String
Dim strUserName As String, strPath As String
Dim reportName As String
Dim Criteria As String
filename = Me.[Prepared By] & "-" & "GFM" & "" & Me.[Quote Ref] & "-" & Me.[Minor Works Title]
strUserName = Environ("username")
strPath = "C:\Users\& Strusername &\GRAHAM\GFM Team - Documents\Quotes" & filename & ".PDF"
reportName = "QuoteDetailsT1"
Criteria = "[Quote Ref] = " & Me.[Quote Ref]
DoCmd.OpenReport reportName, acViewPreview, , Criteria, acHidden
DoCmd.OutputTo acOutputReport, reportName, acFormatPDF, strPath, True
DoCmd.Close acReport, reportName, acSaveNo
End Sub