Results 1 to 6 of 6
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Email report automatically to every ID but with own ID

    I am using

    Code:
    Private Sub Command4_Click()
    
    
    Dim db As dao.Database
    Dim rs As dao.Recordset
    Dim strsql As String
    
    
    
    
    strsql = "SELECT tblPersons.ID, tblPersons.Title, tblPersons.Absent, tblPersons.PersonChecked, tblPersons.Email " & vbCrLf & _
    "FROM tblPersons;"
    
    
    Set db = CurrentDb()
    Set rs = db.OpenRecordset(strsql)
    
    
    rs.MoveFirst
    Do Until rs.EOF
    rs.Edit
    If rs!Absent = True Then
    rs!PersonChecked = True
    
    
    
    
    DoCmd.OpenReport "rptPersons", acViewPreview, , "ID=" & rs!ID
    DoCmd.SendObject acSendReport, "rptPersons", "PDFFormat(*.pdf)", rs!Email, , , "test email please delete", rs!Title, no
    DoCmd.Close acReport, "rptPersons", acSaveNo
    End If
    
    
    
    
    
    
    rs.Update
    rs.MoveNext
    Loop
    MsgBox "all done"
    rs.Close
    Set rs = Nothing
    End Sub
    however with this method it has to open up each report first then email it - I would prefer it without having to open the report in order to filter it by id

    I was hoping to change the reports record source instead and never docmd.openreport



    is there a way around this?

  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,642
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by pbaldy View Post
    ...that's for forms yes?

    I need to filter a report before I send it via docmd.sendobject

    without opening the report...

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Forms? The title says

    Emailing a different report ...

    this filters the report from within.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by pbaldy View Post
    Forms? The title says

    Emailing a different report ...

    this filters the report from within.
    I read that later sorry

    It seems you can't filter sendobject...

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    You're missing the point. With that method, the report filters itself. You don't need SendObject to do it.
    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. Automatically email a from based on query
    By timmyjc18 in forum Forms
    Replies: 4
    Last Post: 08-13-2013, 01:21 PM
  2. Replies: 2
    Last Post: 10-05-2012, 01:50 PM
  3. Replies: 1
    Last Post: 08-31-2012, 01:47 PM
  4. Replies: 1
    Last Post: 11-17-2010, 11:24 AM
  5. Automatically email report
    By Lockrin in forum Access
    Replies: 6
    Last Post: 01-18-2010, 12:35 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