Results 1 to 12 of 12
  1. #1
    ijo68 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2021
    Posts
    39

    How to Send a Report (.pdf) to the Attachment field of a record?

    Hello All,



    I am using the following code to send a report to the "FSGs" folder on the C drive. I will like to instead send to the attachment field of the record using command5 button, can anyone point me in the right direction please.. Thanks in advance.

    Private Sub Command5_Click()
    On Error Resume Next
    Dim fileName As String
    Dim filepath As String


    fileName = "Activity Report"
    filepath = "c:\FSGs" & fileName & ".pdf"
    DoCmd.OutputTo acOutputReport, "DailyActRpt", acFormatPDF, filepath


    End Sub

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,910
    A). It is not recommended as it just bloats the DB
    B). If you insist on doing it, save to pdf. then find the file and add to the attachment field.?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    I agree. No attachments in tables, only file paths as text.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    ijo68 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2021
    Posts
    39
    Quote Originally Posted by Micron View Post
    I agree. No attachments in tables, only file paths as text.
    Can I use VBA to send hyperlink to a field?

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,910
    Yes, Use a hyperlink to the flie location or a function that opens up whatever the file is, with the native app on the computer.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    It's enough to just store the file path in the table field without formatting it a hyperlink and use code/macro to follow it - unless you're working with open tables, which you should not be doing.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    ijo68 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2021
    Posts
    39
    Quote Originally Posted by Welshgasman View Post
    Yes, Use a hyperlink to the flie location or a function that opens up whatever the file is, with the native app on the computer.
    I changed the attachment field to a hyperlink field , the added " HypFld = filepath " to my code.... that inserted the file path ( C\FSGs\Activity Report.pdf ) as a hyperlink into the field(HypFld), but when I click on it , doesn't do anything.. It is a valid path since it works when I place it in the file explorer window.. any idea why it won't work from the field?

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    I believe hyperlink syntax for Windows files is file:/// then the path. You're basically dealing with something that was meant for a browser, so file URL's start with what I posted.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,910
    You do not have the : for the drive letter either?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    Probably just a typo. It is in the code of post #1.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,910
    Quote Originally Posted by Micron View Post
    Probably just a typo. It is in the code of post #1.
    That code does not have a closing \ for the folder either?

    Why don't people copy and paste what they ACTUALLY use?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    ijo68 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2021
    Posts
    39
    Needed to add this to the onClick event of the hyperlink field... Application.FollowHyperlink Me.HypL.Value

    Than you

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

Similar Threads

  1. Send attachment as email attachment.
    By JulieAHop in forum Programming
    Replies: 1
    Last Post: 03-10-2017, 10:25 AM
  2. Send Report & table as attachment MS access
    By Skhaliq in forum Access
    Replies: 1
    Last Post: 09-19-2015, 10:06 AM
  3. Replies: 2
    Last Post: 09-03-2015, 11:33 AM
  4. Replies: 3
    Last Post: 10-13-2014, 05:48 PM
  5. Replies: 16
    Last Post: 04-30-2012, 07:12 AM

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