Results 1 to 5 of 5
  1. #1
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94

    SendObject with dynamic attachment name

    Hi - I am attempting to send a PDF of a report via email and the SendObject function but I don't know how to create the attachment with a dynamic name. What happens is the name of the report gets passed to the name of the attachment.



    Code:
    DoCmd.SendObject acSendReport, "rpt_Certificate", acFormatPDF, "replace.me@domain.com", , , Subject, Body, Yes, ""
    What I would like to do is name the attachment from a field.

    Something similar to this:

    Code:
    DoCmd.SendObject acSendReport, "rpt_Certificate" [TaskSR] & ".PDF", acFormatPDF, "replace.me@domain.com", , , Subject, Body, Yes, ""

  2. #2
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    I do this by previewing the report and renaming the report in the OnLoad property of the report, but I am sure you could do something similar bypassing the need to open the report.

    Basically I set the report caption by populating a field on my form with the Customer Name (which will also be part of the report name) and add the order number (also a text field on the form) and date information to the report name as follows:

    Me.Caption = [Forms]![frm_Main]![txt_Cust_Name_for_Report] & " Order " & [Forms]![frm_Main]![txt_OrderNum] & " - Schedule as of " & Date

    The final product sends the attachment with the dynamically assigned name.
    Last edited by Stingaway; 10-21-2011 at 12:37 PM. Reason: Clarification

  3. #3
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    Thanks - that worked did exactly as you said. It doesn't work when it's sent through SendObject though. Anyone know how we can put the two together?

  4. #4
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    How are you firing the send object? Control button? You can do the same thing by defining the report name in the code (instead of the onload event) before you execute the send object command. Pass the report name as the variable and you should be good to go.

  5. #5
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    I am doing it via a click event. I have not been able to determine where I place the variable in the attachment name.

    Any clues?

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

Similar Threads

  1. Dynamic Form, Dynamic labels/ captions?
    By JFo in forum Programming
    Replies: 15
    Last Post: 10-12-2011, 08:33 PM
  2. Quick Q about SendObject
    By Hello World in forum Forms
    Replies: 1
    Last Post: 10-03-2011, 10:01 AM
  3. SendObject
    By weshader in forum Access
    Replies: 1
    Last Post: 11-09-2009, 04:19 PM
  4. SendObject Message
    By williammarino in forum Forms
    Replies: 4
    Last Post: 10-06-2009, 01:54 AM
  5. DoCmd.SendObject Help
    By bgreer5050 in forum Programming
    Replies: 0
    Last Post: 01-12-2007, 06:27 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