Automatic Report in Email

pianoprodigy

Registered User.
Local time
Today, 11:28
Joined
Apr 22, 2003
Messages
42
Automatically Sending A Report (1 record) as E-mail

I searched and found this code which seems to work; however, I just need to show one record on the report. Below is the code that I found...

Code:
Private Sub YourButton_Click()

      Dim EmailApp, NameSpace, EmailSend As Object

      DoCmd.OutputTo acOutputReport, "Report1", "snapshotformat", "C:\Temp\Report1.snp"
      
      Set EmailApp = CreateObject("Outlook.Application")
      Set NameSpace = EmailApp.getNameSpace("MAPI")
      Set EmailSend = EmailApp.CreateItem(0)
      
      EmailSend.To = "email@wherever.bla"
      EmailSend.Subject = "Your Subject Here"
      EmailSend.Body = "Hello," & vbCrLf & vbCrLf & "Attached is the latest Snapshot"
      EmailSend.Attachments.Add "C:\Temp\Report1.snp"
      EmailSend.Send
      
      Set EmailApp = Nothing
      Set NameSpace = Nothing
      Set EmailSend = Nothing

End Sub

Another button in the form calls the current record to simply print it using the following code:

Code:
Private Sub Command325_Click()
Me.Refresh
DoCmd.OpenReport "AISReport", acViewNormal, , "[ID] = " & Me("ID")

End Sub

Any ideas??? There are like 17,000 records in the table. I only want to display the one ID in this report. I've tried for hours, and I'm tired of guessing...

Thanks for the help!

Alan
 
Is your report based on a query? If yes, place the following in the criteria of the query under the 'ID' column changing 'YourForm' to the form in question.

[forms]![YourForm]![ID]

HTH
 
I have a simular situation where I have a db that can assign tasks to a project. Ive seen threads about sending out emails but cant figure out how to do this.....
Im posting a striped down sample of my main form w/ a subfrm that users enter the tasks.....
There is 2 cbo's that the user selects the person to be tasked and who is assigning the task[they are bound to a ODBC table so they dont funtion if your using]
But I was hoping to have it where when the task is typed in the user clicks some button that says send this via email... And the user selected for the task would get the task info.
Not in the sample db, but I do have a tbl that has all the employee ID's & there email address's....
 

Attachments

I have used the same criteria and works well.

On my form i have just created a button from the wizard and selected to email the report as an attatchment. when pressed the user is asked what format it should be sent in. Is there anyway we can specify in the code what format we want instead of leaving it up to the user.


Private Sub emailpartdetails_Click()
On Error GoTo Err_emailpartdetails_Click

Dim stDocName As String

stDocName = "rptIndividualPartfromfrmpartlistresults"
DoCmd.SendObject acReport, stDocName

Exit_emailpartdetails_Click:
Exit Sub

Err_emailpartdetails_Click:
MsgBox Err.Description
Resume Exit_emailpartdetails_Click

End Sub

I.e I would like to specify it to be excel 97-2000 as asked.

Thanks in advance
 

Users who are viewing this thread

Back
Top Bottom