Results 1 to 7 of 7
  1. #1
    griztkojr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    30

    Unhappy Report Error

    Good afternoon ALL,

    I generate a PDF report on MS Access which I email to a recipient. The problem is that the name on the report and the data on the actual report differ. So, if I have the record for Jane Doe on the screen, Access generates and emails the data for John Doe. Below is the code I am using. What am I doing wrong? Please help!!



    Code:
    Dim oApp As New Outlook.Application
    Dim Oemail As Outlook.MailItem
    Dim FileName As String
    Dim FilePath As String
    Dim stLinkCriteria As String
    
    stLinkCriteria = "[PAF_ID]  = " & Me![PAF_ID]
    
    
    FileName = Me.EE_LastName & "EEID " &Me!EEID & "JobID " & Me!PAF_JobID & "PAFID "& Me!PAF_ID
        FilePath ="\\fps01\Output\" & FileName &".pdf"
        DoCmd.OpenReport"rptPAF", acViewPreview, , stLinkCriteria, acHidden
        DoCmd.OutputToacOutputReport, "rptPAF", acFormatPDF, FilePath
        If oApp Is NothingThen
            Set oApp = NewOutlook.Application
            End If
            Set Oemail =oApp.CreateItem(olMailItem)
            With Oemail
                .To ="reception@perfectbuilding.com"
                .Subject ="PAF for: " & Me.EE_LastName & ", " &Me.EE_FirstName & "_EEID" & Me.EEID
               .Attachments.Add FilePath
                .Send
            End With
    
           Set Oemail =Nothing
           Set oApp =Nothing
    
           Kill FilePath

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    No idea. Code looks okay. Would have to review db structure and form and report design. If you want to provide db, follow instructions at bottom of my post.

    What event is this code in - a button Click?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    What to Jane Doe and John Doe have in common? Your filename seems to use LastName as part of the name.
    Can you confirm the info for EEID is different for these people and also that you are using the proper EEID. You can
    Debug.Print Me.EEID & " " & me.firstname & " " & me.lastname

  4. #4
    griztkojr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    30
    Quote Originally Posted by orange View Post
    What to Jane Doe and John Doe have in common? Your filename seems to use LastName as part of the name.
    Can you confirm the info for EEID is different for these people and also that you are using the proper EEID. You can
    Debug.Print Me.EEID & " " & me.firstname & " " & me.lastname
    Hi Orange,

    Jane Doe and John Doe don't have anything in common. EEID is unique for each record. When I debug the info matches the record on screen.

  5. #5
    griztkojr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    30
    Quote Originally Posted by June7 View Post
    No idea. Code looks okay. Would have to review db structure and form and report design. If you want to provide db, follow instructions at bottom of my post.

    What event is this code in - a button Click?
    How have you been June7? Network doesn't allow me to upload the db. I'll try to get some screen shots.

  6. #6
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    I take it PAF_ID is also unique for each employee? could you change the stLinkCriteria to work with EEID?

  7. #7
    griztkojr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    30
    Quote Originally Posted by Robyn_P View Post
    I take it PAF_ID is also unique for each employee? could you change the stLinkCriteria to work with EEID?
    Hi Robyn,

    You are correct PAF_ID is unique as well. I can't change to use EEID because there will be multiple EEIDs in the table but only one PAF_ID.

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

Similar Threads

  1. Report to PDF error
    By Homegrownandy in forum Programming
    Replies: 22
    Last Post: 02-07-2017, 03:23 AM
  2. closing report pop-up error
    By ronni in forum Reports
    Replies: 1
    Last Post: 07-27-2014, 10:11 PM
  3. Report Error
    By drunkenneo in forum Programming
    Replies: 2
    Last Post: 09-17-2013, 06:29 PM
  4. #Name? Error in Report
    By kristyspdx in forum Reports
    Replies: 4
    Last Post: 12-01-2011, 11:11 AM
  5. Report error
    By indira in forum Reports
    Replies: 2
    Last Post: 03-12-2011, 03:13 PM

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