Share via

Can you save an access report as a pdf and store it as an attachment in current db

Anonymous
2012-12-19T15:30:15+00:00

Was wondering if there was a way to take an access report and store it in an attachment field of the current db using VBA?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2012-12-19T16:13:38+00:00

You can, but...

Using attachments is not recommended.  It is better to merely store the file path & name and use code to open/edit/manipulate it as required.

Regardless, to answer you question, see::

To export the report to a pdf file, you'd do something like (or you could also create a macro to do the same):

DoCmd.OutputTo acOutputReport,"YourReportName",acFormatPDF,"FullPathAndFileName4ThePDF"

To save the newly created PDF as an attachment, see:

http://blogs.office.com/b/microsoft-access/archive/2007/08/24/adding-removing-and-saving-files-from-the-new-attachment-field-in-access-2007.aspx

http://stackoverflow.com/questions/4787149/how-to-auto-attach-images-in-access-2010-using-vba-macros

Was this answer helpful?

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2012-12-19T17:19:46+00:00

    Attachments take up a lot of space in your db and if you have a lot(?) if them, you will run into the 2GB limit on db file size.

    The tide re macros has not changed so much as the coastline has dramatically shifted over the years.  The macro processor has been essentially redone as many new features have been added.  The many new macro features were necessary because of Access's new (A2007) web database capabilities, which do not allow any VBA code at all.  Also, the new table trigger features can only be done using what's called Data Macros (because the back end db is not executing Access as the front end db does).

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2012-12-19T17:19:08+00:00

    Attachments lead to database bloating.  MS improved upon embedding file in Access 2007, but regardless, as much as possible, it is to be avoided.  It can also pose a compatibility issue should you ever need to downgrade your accdb to an mdb for whatever reason.

    As for macro, well, I always tended to avoid them.  VBA is much more powerful and in my opinion, much easier to work with.  That said, with the creation of Access web databases, VBA does not work, so you have no choise but to use Macros is such dbs.  So there is a push back towards macros for this reason.  So if you are developing a web database, or plan to one day convert your db to a web database, then you need to not use any VBA, and only use macros.  Otherwise, use what you are most comfortable with.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2012-12-19T16:48:23+00:00

    Thank you for the guidence... I will take this as the answer and go with your recomendations. However, this leads me to as you two follow-up questions. Why do you say it's "not recommended" to use attachments? Do you suspect that will be going away or something? And my other question is this... Back many years ago (Access ver. 2) it was recommended to not use macros as VBA was much faster. But i've notice, especially in Access 2010, that all the generated code for buttons, functions, etc. all seem to be using macro's. Has the tied turned on that old premis? Just curious - looking to tap into your wisdom!

    Ron

    Was this answer helpful?

    0 comments No comments