krishnaoptif
Board Regular
- Joined
- Sep 17, 2010
- Messages
- 140
Hi Experts,
I am using below code in my access report to download in to pdf report in a folder... this code is working fine in Access 2007 at my home system... but in my office i am using Access 2003 so in 2003 version the below code is not working ... this is giving me below Error msg ---
"run-time error '2282' the format in which you are attempting to output the current object is not available"
I am waiting for your reply..
my code which is not working with Access 2003 but working fine with Access 2007
I am using below code in my access report to download in to pdf report in a folder... this code is working fine in Access 2007 at my home system... but in my office i am using Access 2003 so in 2003 version the below code is not working ... this is giving me below Error msg ---
"run-time error '2282' the format in which you are attempting to output the current object is not available"
I am waiting for your reply..
my code which is not working with Access 2003 but working fine with Access 2007
Code:
Public Function PrintPDF2(SrcReport As String, CustName As String)
Dim MyFilter As String
Dim MyPath As String
Dim MyFilename As String
'create new folder
If Len(Dir("E:\Krishna\Live\Joe\PDFReport\" & Format(Date, "DD-MMM-YYYY") & "", vbDirectory)) = 0 Then
MkDir "E:\Krishna\Live\Joe\PDFReport\" & Format(Date, "DD-MMM-YYYY") & ""
End If
'I place the file on a different folder depending on the date stated in a field called "Date"
MyPath = "E:\Krishna\Live\Joe\PDFReport\" & Format(Date, "DD-MMM-YYYY") & "\" '& Format(Date, "yyyy")
'State the filename. Here I use YYYY-DD-MM-Event.pdf
MyFilename = Format(Date, "DD-MMM-YYYY") & "_" & CustName & ".pdf"
'Let's print and save. Once you see it works, you can change True to False so that the file created is not opened after completion.
DoCmd.OpenReport SrcReport, acViewPreview
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilename, False
'Let's close our previewed report
DoCmd.Close acReport, SrcReport
End Function