Results 1 to 9 of 9
  1. #1
    Alvin Schultz is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2014
    Posts
    4

    Automatically exporting a report on closing access

    I am working on an elderly friend's database. He sells things on layaway. If something were to happen to him, he wants his daughter to be able to complete the transactions (yes he is very dedicated). I've created a report. But he doesn't always remember to export the report. So I would like to automatically export the report to a file on his desktop when he closes down access each night. I've read about and can create an outlook task, but he doesn't use outlook and so that process will likely fail. Any ideas?


    Thanks for your help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Have code in the Close event of a form that never closes until the database is quit. I use a Main Menu form or this could be a hidden 'splash' form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Alvin Schultz is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2014
    Posts
    4
    I know you are busy, but my coding is encrusted with rust. I can get to the point of entering the code, but need more help if possible. The report name is "Layaways Pending" and I would like to export it to a Word document on the desktop. IF you have time I would appreciate more help. Thanks again.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe something like

    DoCmd.OutputTo acReport, "rptName", acFormatRTF, "C:\PathToDirectory\Filename.rtf"

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Can export to Word RTF (rich text format).

    I have no idea how to programmatically save document to desktop. The little research I did indicates it is not easy.

    Alternative is to first save document to a folder location then set a desktop shortcut to the file. Use code to replace the file each day.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Path to desktop should be something like this

    C:\Users\UserName\Desktop\

  7. #7
    Alvin Schultz is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2014
    Posts
    4
    Thanks for your help. I'll try doing this.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Okay, maybe not so hard. The USERNAME can be pulled from the system with:

    Environ("USERNAME")

    Yes, type it exactly like that.

    DoCmd.OutputTo acOutputReport, "report name", acFormatRTF, "C:\Users\" & Environ("USERNAME") & "\filename.doc"

    Wait - it saved the file but don't see it on desktop.

    This works:

    Docmd.OutputTo acOutputReport, "report name", acFormatRTF, "C:\Documents and Settings\All Users\Desktop\filename.doc"

    or

    Docmd.OutputTo acOutputReport, "report name", acFormatRTF, "C:\Documents and Settings\" & Environ("USERNAME") & "\Desktop\filename.doc"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Alvin Schultz is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2014
    Posts
    4
    Thank you.

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

Similar Threads

  1. Exporting a Access Report to an Excel File
    By Coffee in forum Import/Export Data
    Replies: 2
    Last Post: 07-28-2014, 11:32 AM
  2. Automatically Closing Print Preview Window
    By chris.williams in forum Reports
    Replies: 5
    Last Post: 08-07-2012, 05:02 PM
  3. automatically run report in access
    By cwang0129 in forum Access
    Replies: 1
    Last Post: 06-26-2012, 08:03 PM
  4. Replies: 3
    Last Post: 12-05-2011, 02:19 PM
  5. Closing a form automatically
    By accessnewb in forum Forms
    Replies: 27
    Last Post: 07-22-2011, 05:58 PM

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