DoCmd.sendobject method, customize the attachment file name (1 Viewer)

Leo_Polla_Psemata

Registered User.
Local time
Today, 06:20
Joined
Mar 24, 2014
Messages
364
Hi
With DoCmd.SendObject methode, we can send reports as email attachments.
Could we customize the attached file name ?
My report is tuned to filter on load [Forms]![FormName]![FieldName]

With the below line, the report on email attachment gets always the same name, the report name (or report caption)
DoCmd.SendObject acSendReport, reportName, acFormatPDF, "recipient@email.com", , , "Subject", "Message", True
Could we customize so the attachment gets a name based on a field from report ?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:20
Joined
Oct 29, 2018
Messages
21,474
or report caption
That is your key. You can open the report in hidden view and then modify the caption to match the name you want and then close the report before using SendObject.
 

Leo_Polla_Psemata

Registered User.
Local time
Today, 06:20
Joined
Mar 24, 2014
Messages
364
That is your key. You can open the report in hidden view and then modify the caption to match the name you want and then close the report before using SendObject.
Sure, but, if user has to do all this manually, it is better to keep on as is, send emails with the same attachment name.
 

bastanu

AWF VIP
Local time
Today, 06:20
Joined
Apr 13, 2010
Messages
1,402
It doesn't have to be done manually (you have to open it in design view to change the caption)

Cheers,
 

Leo_Polla_Psemata

Registered User.
Local time
Today, 06:20
Joined
Mar 24, 2014
Messages
364
It doesn't have to be done manually (you have to open it in design view to change the caption)

Cheers,
This report, is a kind of invoice. It opens on filter
[Forms]![FormName]![FieldName] , its different each time

Then i send each "invoice" to each client, the .pdf document has ALWAYS the same name, the name of the report "VGM"
I would like to get the document name VGM01, VGM02 and so on, "VGM"&[FIELDNAME] which is different piece of data each time.

One problem is that when clients receive by me 5 different emails with 5 different attached documents that have the same name,
when they download and file/save on same folder , they may "delete" the older pdf by mistake.


Example in form,
This simple line, change the caption of a form without any issue
me.Caption = "Customer: " & FirstName & " " & LastName
Why not as simple as that in reports ?
 
Last edited:

bastanu

AWF VIP
Local time
Today, 06:20
Joined
Apr 13, 2010
Messages
1,402
Please review the attached sample.

Cheers,
 

Attachments

  • Database60.accdb
    436 KB · Views: 125

theDBguy

I’m here to help
Staff member
Local time
Today, 06:20
Joined
Oct 29, 2018
Messages
21,474
(you have to open it in design view to change the caption)
Can't look at your demo right now, but I thought hidden view is enough. Didn't think design view was also necessary.

Sent from phone...
 

bastanu

AWF VIP
Local time
Today, 06:20
Joined
Apr 13, 2010
Messages
1,402
acViewPreview would also work; acHidden is the WindowMode argument vs the View argument the default for View is acViewNormal which prints the report).

Cheers,
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:20
Joined
Oct 29, 2018
Messages
21,474
acViewPreview would also work; acHidden is the WindowMode argument vs the View argument the default for View is acViewNormal which prints the report).

Cheers,
So, design view wasn't necessary, right? Sorry I forgot to mention print preview, but would report view work as well? I specifically mentioned hidden view, because I didn't think the user would need to see the report before sending it.

Sent from phone...
 

Users who are viewing this thread

Top Bottom