Results 1 to 10 of 10
  1. #1
    ecalvert47462 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    17

    emailing a report based on a combobox selection

    I am fairly new to access so hopefully I am not asking a silly question.



    I am using access 2010...and i have a form with a combobox on it...and in that combobox shows a list of employees names. When i currently select the name of the person that i want, it creates their own individual report of their workload.

    What I want to do is to be able to select that person and it generates their individual report and then attaches it in an email to that individual.

    Thanks,
    E

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Why is the report generated? Do you have an event handler for the combobox? Is there a button the user clicks? It may be as simple as adding a Docomd.SendObject line of code to your existing code.

    Can you post your existing code?

  3. #3
    ecalvert47462 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    17
    The report is generated when I want to see the individual's workload that they have, I am the only one that will be using it...and when the name is selected, an OnClick event then takes the name I have selected...runs the query and then the individual's report pops up in a pdf.

    I want to be able to select the person, it generates the report and then generate an email to that specific person.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Can you post the code in your Click Event Handler?

  5. #5
    ecalvert47462 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    17
    Option Compare Database
    Private Sub Combo0_AfterUpdate()
    DoCmd.OpenQuery "P Agent Selection Query", acViewNormal, acEdit
    DoCmd.Close acForm, "frmP Agent Form"
    End Sub

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Did you build a report that displays the results you want to email? You mentioned a PDF file? Is this file based on a report? What is the report name?

    Can you post the RowSource for your Combo0? It is found in the Data tab of the properties window. Use the mouse right click and zoom into the RowSource to insure you select all of the code and post it here.

    The code you posted in post # 5 is opening a query. I do not see an object that can be emailed directly.

  7. #7
    ecalvert47462 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    17
    I zoomed in on the row source and below is what i copied for the Combo0 box..

    SELECT [PURCHASING AGENT LIST].[Purchasing Agent(CXM)] FROM [PURCHASING AGENT LIST] ORDER BY [Purchasing Agent(CXM)];

    I did build a report that generates from the query, after a name is selected.

    Sorry about all this...I feel so spacey right now..lol

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Are you using primary keys for your table PURCHASING AGENT LIST? What is the data type? What is the name of your report? Recommend not using special characters or spaces in names for forms, tables, reports, controls, etc.

  9. #9
    ecalvert47462 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    17
    No primary keys.
    Data type is text
    Name of report is: Updated SWIP Report

    Maybe I'm not asking the correct question.

    I open my form, select an employee's name from the combo box and then on click it runs the query and generates the report and it pops up in print preview mode....all i want it to do for me is to put the report in an email as an attachment (which i know how to send object in an email macro) and based on the person's name i selected it will go ahead and autofill the "To:" part of the email with that individual's individual email address..

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I simply have not been getting the answers I need to help you. Perhaps you are working on something that is hypothethitacal. Can you post the code in your click control button click event?

    Code like this should work in a click event

    Code:
    Dim strEmail As String
    Dim strCriteria As String
    strEmail = "EmailAddress@Domain.com"
    strCriteria = "[Purchasing Agent(CXM)] = '" & Me.Combo0.Value & "'"
    DoCmd.OpenReport "Updated SWIP Report", acViewPreview, , strCriteria, acWindowNormal
    DoCmd.SendObject acSendReport, "Updated SWIP Report", acFormatPDF, strEmail, , , "Subject Line", "Body of Email", True

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

Similar Threads

  1. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  2. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  3. Replies: 6
    Last Post: 07-28-2011, 04:07 AM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 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