Results 1 to 2 of 2
  1. #1
    meikke is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    4

    SendReport - variable subject


    At the moment I am redesigning someone else's personell registration system for work. The idea is that the management of the concerning office will be notified of newly hired employees, renewed contracts and so on through email, which is sent by hitting a particular button. The idea is to put the name of the concerning employee in the subject line. I have managed to get that to work with the following code:
    Code:
    DoCmd.SendObject acSendReport, "new employee", "PDFFormat(*.pdf)", "someone[@]somewhere.com", "", "", "New employee" & " - " & Forms![form name]![Name] & ", " & Forms![form name]![Initials] & " " & Forms![form name]![Insertion], "Dear colleages, so and so on", True, ""
    The only problem is, it sends the wrong name (from the first record). Which brings me to my question: does anyone know how to retrieve and send the name in the current record? I have tried using Me.name etcetera, but that produced an error message. Thanks in advance.

  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,518
    Well, this:

    Forms![form name]![Name]

    should return the value from whatever record is currently selected on the form. Is the desired record selected on that form? Me.Name would also work the same way, but because of the reserved word would need to be bracketed:

    Me.[Name]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  2. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  3. VBA check for email subject line
    By problem_addic in forum Access
    Replies: 4
    Last Post: 03-12-2010, 02:33 PM
  4. Field Name into Subject/Body of an email?
    By Stanggirlie in forum Programming
    Replies: 0
    Last Post: 01-05-2009, 11:51 AM
  5. Email field name into subject/body?
    By Stanggirlie in forum Access
    Replies: 0
    Last Post: 01-02-2009, 11:07 AM

Tags for this Thread

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