Email Report Command Button

BobJ

Kestrel - Crawley
Local time
Today, 03:59
Joined
Mar 22, 2007
Messages
47
Hi,

Ive set up a command button on a Client List form which is supposed to email a client a specific invoice.

I have a few questions tho regarding this service.. i would try it myself but i have a dataless database atm :)

If i want to send a client a particular invoice by email and i click on this button will it only send them invoices related to their ClientID autonumber or
will it send all the invoices for each client?

And what if the invoice report i want to send them is only related to one particular Order, would i need to modify the code if i wanted to achieve this?

I guess this applies to printing and saving invoice reports too.

Cheers.
 
Last edited:
You need to set up the code behind the button to filter accordingly.
If you want to send all invoices for a given client, filter on his/her ID. If you want just a specific invoice, filter on Invoice Number or ID & Date, or something.

There are some good examples on the forum of how to do this and it's saved me a lot of work. I need to produce a lot of reports/invoices and the process I opted for was:

1) Open the report, filtered accordingly
2) Save the report to a file somewhere
3) Attach the saved file to an email
 
thanks alot mate, think i gave the wrong impression when i created this thread. Was only after the theory of how it worked wasnt askin for anyone to fix my problems ;)

Cheers alc
 
I guess this applies to printing and saving invoice reports too.
Bob, I think you got close to answering your own question here.... I assume you would put a "Preview" button to look at the invoice before sending it to a client...Whatever filter or query is used to produce the report is how you would alter what is sent to the client. No need to change the code.
The basic command is
DoCmd.SendObject [objecttype],[objectname],[outputformat],[to],[cc],[bcc],[subject],[messagetext],[editmessage],[templatefile]


So in the code below... Whatever you view (as a report..acSendReport) when looking at "rptCurrentReport" is what is going to be sent to the client. This could be one invoice or 100. Just depends on how you set it up.....What you see is what they'll get :)


Dim stDocName As String

stDocName = "rptCurrentReport"

DoCmd.SendObject acSendReport, stDocName, "SnapshotFormat(*.snp)", "whoever@someplace.com", "", "", [SubjectLine], "MessageText ", False, ""

PS.... I like to send mine in "Snapshot Format" simply to know that what I am previewing is exactly what any recipient is viewing.
 

Users who are viewing this thread

Back
Top Bottom