Hello,
I want to save directly a report from access (2010) into file pdf without open preview report of pdf.
Now I use:
DoCmd.OpenReport "REPORT", acViewPreview, , , acWindowNormal
But I don't want open and then save it.
Can you help me?
Thanks
Hello,
I want to save directly a report from access (2010) into file pdf without open preview report of pdf.
Now I use:
DoCmd.OpenReport "REPORT", acViewPreview, , , acWindowNormal
But I don't want open and then save it.
Can you help me?
Thanks
I use this 'technique' quite a lot:
1. Create a Macro that [among other things] has an 'ExportWithFormatting' action.
2. Set the 'Output Format' to PDF Format.
3. In the Code that gets run ['Called'] from my 'AutoExec' Macro, I [among other things] execute the Macro that has the 'ExportWithFormatting' action - using something like this:
I'm not sure how proficient you are with Access but I'll add this anyway:Code:DoCmd.RunMacro "Mcr_Macro_Name"
If you create a Macro named 'AutoExec' - it will execute every time you open the database.
If you do NOT want it to execute - hold down the Shift key while you are opening the database.
What I do is set the database to open using the Windows Task Scheduler - before anyone gets to work in the morning.
When the Task Scheduler opens the database - the AutoExec macro is executed.
The AutoExec macro uses a 'RunCode' action that executes some code - including the DoCmd.RunMacro "Mcr_Macro_Name".
Please let me know if you have any questions.
Last edited by Robeen; 04-16-2013 at 08:08 AM. Reason: Incomplete post.
The solution is: MyFilter = "Field = State your filter here as usual"
'I place the file on a different folder depending on the date stated in a field called "Date"
MyPath = "C:\temp\"
MyFilename = "test" & valore & ".pdf" 'Format(Me.EventDate, "yyyy") & _
'"-" & Format(Me.EventDate, "dd") & Format(Me.EventDate, "mm") & _
'"-" & Me.Event & ".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 "report_new", acViewPreview, , ""
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilename, True
'Let's close our previewed report
DoCmd.Close acReport, "report_new"