Results 1 to 5 of 5

Thread: email report

  1. #1
    Join Date
    Apr 2004
    Posts
    182

    Unanswered: email report

    I am trying to email a report using the code below but this trys to email all records not just the one selected ?? This code works fine for Preview and print ?

    Private Sub cmdemail_Click()
    On Error GoTo Err_cmdemail_Click

    Dim stDocName As String
    Dim strCriteria As String



    If Me.fsubQuoteHead.Form.optCarMed = -1 Then
    stDocName = "rptQuote"
    Else
    If Me.fsubQuoteHead.Form.optCarMed = 0 Then
    stDocName = "rptQuoteM"
    End If
    End If
    strCriteria = "[id]= " & Me!fsubQuoteList![id] & ""
    DoCmd.SendObject acReport, stDocName, , strCriteria

    Exit_cmdemail_Click:
    Exit Sub

    Err_cmdemail_Click:
    MsgBox Err.Description
    Resume Exit_cmdemail_Click

    End Sub
    Last edited by livvie; 07-10-04 at 08:05.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Try this:

    Code:
    Private Sub cmdemail_Click()
    On Error GoTo Err_cmdemail_Click
     
    Dim stDocName As String
    Dim strCriteria As String
     
    'Check whether it is a quote or order confirmation for Recipient1 or Recipient2 and use appropriate doc.
     
    If Me.fsubQuoteHead.Form.optCarMed = -1 Then
    stDocName = "rptQuote"
    Else
    If Me.fsubQuoteHead.Form.optCarMed = 0 Then
    stDocName = "rptQuoteM"
    End If
    End If
    strCriteria = "[id]= " & Me!fsubQuoteList![id] & ""
    DoCmd.OpenReport stDocName, acViewPreview, , strCriteria, acHidden
    DoEvents
    'Yours...DoCmd.SendObject acReport, stDocName, , strCriteria
    DoCmd.SendObject acSendReport, , DocFormat, Recipients, , , MailSubject, MailMessage, False
    DoCmd.Close acReport, stDocName
     
    Exit_cmdemail_Click:
    Exit Sub
     
    Err_cmdemail_Click:
    MsgBox Err.Description
    Resume Exit_cmdemail_Click
    End Sub
    Last edited by CyberLynx; 07-11-04 at 01:03.

  3. #3
    Join Date
    Apr 2004
    Posts
    182
    This code gives me the following error.
    The Object Type argument for the action or method is blank or invalid.

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    Make sure all parameters for for the provided code are correct and placed within their proper location. See Acess help reguarding the SendObject function.



  5. #5
    Join Date
    Apr 2004
    Posts
    182
    Got it thanks.
    DoCmd.OpenReport stDocName, acViewPreview, , strCriteria, acHidden
    DoEvents
    DoCmd.SendObject acSendReport, stDocName, , , , , , strCriteria, False
    DoCmd.Close acReport, stDocName

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •