Results 1 to 3 of 3
  1. #1
    alex__ice is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    2

    Save a report file without preview

    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

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    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:
    Code:
    DoCmd.RunMacro "Mcr_Macro_Name"
    I'm not sure how proficient you are with Access but I'll add this anyway:
    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.

  3. #3
    alex__ice is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    2
    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"

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Report Preview
    By roaftech in forum Reports
    Replies: 3
    Last Post: 11-15-2012, 01:59 PM
  2. Replies: 10
    Last Post: 06-20-2012, 09:50 AM
  3. Replies: 1
    Last Post: 06-09-2011, 11:10 PM
  4. Report Preview
    By ColPat in forum Programming
    Replies: 2
    Last Post: 06-25-2010, 02:44 PM
  5. Can't see sub report in print preview
    By LoggyDoggy in forum Access
    Replies: 1
    Last Post: 04-20-2010, 05:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums