Results 1 to 3 of 3
  1. #1
    wnicole is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    118

    DoCmd Send Report using emailaddres on Form

    I'm trying to send a simple report from my form using the email address current on form.


    This is my code, but I think I'm missing something can you help?
    Report Name is R_Followupletter
    Field: EmailAddress
    The report and form link fields is "Company" just FYI if you need.

    DoCmd.OpenReport "R_FollowUpLetter", acViewPreview, , "[EmailAddress] = Forms!F_ContactDetails!EmailAddress"

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    The syntax for text from here should work:

    http://www.baldyweb.com/wherecondition.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    A S MANN is offline Advanced System Analyst
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    India
    Posts
    164
    Modify the VBA code as per u r need


    Function SendEmailAttendence() As String
    Dim Sender As String
    Dim stDocName As String
    Dim strBody, strSubject As String
    Sender = [Forms]![All Email Form]![E- Mail ID-Parent]
    strSubject = [Forms]![All Email Form]![Subject]
    strBody = [Forms]![All Email Form]![Massage]
    stDocName = "STUDENT ATTENDENCE (SUBJECT WISE)-EMAIL"
    DoCmd.SendObject acReport, stDocName, acFormatPDF, Sender, , , strSubject, strBody, False
    [Forms]![All Email Form]![EmailStatus].Value = "Send"
    Dim strCourse As String
    Dim strEnrolmentID As String
    Dim strNameOfStudent As String
    strCourse = [Forms]![All Email Form]![Course ID].Value
    strEnrolmentID = [Forms]![All Email Form]![Enrollment ID].Value
    strNameOfStudent = [Forms]![All Email Form]![Name Of Student].Value
    Call LogEmailSendNow(strCourse, strEnrolmentID, strNameOfStudent, Sender, strSubject, strBody)
    End Function

    Function LogEmailSendNow(Course As Variant, EnrolmentID As Variant, NameOfStudent As Variant, EMail_ID As Variant, Subject As Variant, Massage As Variant)
    'Purpose: to log data changes to the tblDataChanges table with values passed to function
    'By PKStormy - 1/1/2011
    'Uses ADO coding
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Dim strSQL As String
    strSQL = "Select * from EMailLog"
    rs.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    rs.AddNew
    rs!Course = Course
    rs!EnrolmentID = EnrolmentID
    rs!NameOfStudent = NameOfStudent
    rs!EMail_ID = EMail_ID
    rs!Subject = Subject
    rs!Massage = Massage
    rs!SendBy = getUser()
    rs!SendOn = Now()
    rs!Modifier = [TempVars]![LogInUser]
    rs![EMail-Regarding] = "ATTENDENCE"
    rs.Update
    rs.Close
    Set rs = Nothing
    End Function

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

Similar Threads

  1. Replies: 11
    Last Post: 09-17-2013, 06:29 PM
  2. Replies: 3
    Last Post: 09-09-2013, 01:48 PM
  3. Replies: 10
    Last Post: 03-26-2012, 08:17 PM
  4. VBA Send Email using DoCmd.SendObject
    By malamute20 in forum Programming
    Replies: 15
    Last Post: 10-05-2011, 12:44 PM
  5. Send Primary Key from a Form To A Report
    By nkuebelbeck in forum Forms
    Replies: 1
    Last Post: 03-18-2010, 12:24 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