Results 1 to 4 of 4
  1. #1
    JackieEVSC is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    70

    Code for reporting a bug to me has a bug in it. (Oh, the irony!)

    I created a form that allows users to report bugs and request new feature. The form works fine, writing the data to a table and saving a report to the users document folder. It also sends me an email to me. That works, too, except it doesn't attach the report. I've attached the code. Can someone tell me where I'm making a mistake? (The irony of my bug report having a bug does not escape me!)

    Thanks for any help you can give me.

    Private Sub SendThis_Click()
    Dim strSQL As String
    strSQL = "INSERT INTO tbl_BugFeature(SubBy,BugDate,BugDesc,ReqDesc) VALUES(" & "'" & Combo18 & "'," & "'" & Text13 & "'," & "'" & Text4 & "'," & "'" & Text6 & "');"
    DoCmd.SetWarnings False
    DoCmd.RunSQL strSQL




    On Error GoTo mcr_bugs_Err


    Dim KillFile As String

    KillFile = "BugFeature.pdf"


    ' 'Check that file exists
    If Len(Dir(KillFile)) > 0 Then
    ' MsgBox "file exists"
    ' 'First remove readonly attribute, if set
    SetAttr KillFile, vbNormal
    ' 'Then delete the file
    Kill KillFile
    End If


    BugMax = DMax("[BugID]", "tbl_BugFeature", "[SubBy] = Combo18")




    DoCmd.OpenReport "rpt_Bug", acViewPreview, , "BugID = " & BugMax
    DoCmd.OutputTo acOutputReport, "rpt_Bug", "PDFFormat(*.pdf)", "BugFeature.pdf", False, "", , acExportQualityPrint
    DoCmd.Close acReport, "rpt_Bug", acSaveYes

    Dim olApp As Object
    Dim objMail As Object
    Dim strAttach1 As String


    strAttach1 = "rpt_Bug.pdf"


    On Error Resume Next 'Keep going if there is an error
    Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open


    If Err Then 'Outlook is not open
    Set olApp = CreateObject("Outlook.Application") 'Create a new instance
    End If
    'Create e-mail item
    Set objMail = olApp.CreateItem(olMailItem)


    With objMail
    'Set body format to HTML
    .BodyFormat = olFormatHTML
    .To = "jackie.egan@evsck12.com"
    .Subject = "Bug Report - Feature Request"
    .HTMLBody = "<htmltags></htmltags>"
    .Attachments.Add strAttach1
    .Send


    DoCmd.Close acForm, "frm_Bug"
    DoCmd.OpenForm "frm_Main"
    MsgBox "Your report has been emailed and a copy has been saved to your documents folder.", vbOKOnly, ""


    mcr_bugs_Exit:
    Exit Sub


    mcr_bugs_Err:
    MsgBox "There was a problem sending this report.", vbOKOnly, ""
    DoCmd.Close acForm, "frm_Bug"
    DoCmd.OpenForm "frm_Main"
    End With

    End Sub

  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
    You save the report as "BugFeature.pdf" then try to attach "rpt_Bug.pdf". Personally I'd use a full path for both, but it may work without.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JackieEVSC is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    70
    Paul,

    I can't believe I didn't catch that . It works now. Thank you!

  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,518
    Happy to help!
    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. code for reporting
    By rakhee in forum Reports
    Replies: 9
    Last Post: 04-29-2013, 11:34 PM
  2. Footer in Reporting
    By gatsby in forum Access
    Replies: 2
    Last Post: 03-12-2013, 09:06 PM
  3. Help with reporting
    By stevo7624 in forum Access
    Replies: 1
    Last Post: 09-03-2012, 09:54 PM
  4. reporting
    By jaykappy in forum Reports
    Replies: 10
    Last Post: 02-16-2012, 03:02 PM
  5. Exception Reporting
    By shexe in forum Queries
    Replies: 16
    Last Post: 09-09-2010, 09:14 AM

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