Solved Save Report to PDF VBA, not saving last part of report (1 Viewer)

Momma

Member
Local time
Tomorrow, 04:31
Joined
Jan 22, 2022
Messages
114
Hi all
I'm running a report consisting of up to 10 pages from VBA. All pages are printing correctly with the DoCmd.OpenReport, however, leaves the last section of the report out when it exports the report to pdf. I've added a pause in between with no luck.
Does anyone know why this is happening?


Code:
Private Sub ReproductionID_Click()

    Dim Filename As String
    Dim Name As String
    Dim Litter As String
        
    Name = Me.Mother
    Litter = Me.MLitterCount
    Filename = "C:\LitterRecords\Litter Record - " & Name & "- Litter " & Litter & ".pdf"

    DoCmd.OpenReport "rptCompleteLitterRecord", acViewPreview, , "ReproductionID=" & Me.ReproductionID & "And MLitterCount=" & Me.MLitter, acHidden
    Sleep 10000
    DoCmd.OutputTo acOutputReport, "rptCompleteLitterRecord", acFormatPDF, Filename
    Sleep 10000
    DoCmd.Close acReport, "rptCompleteLitterRecord", acSaveNo
    
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:31
Joined
Sep 21, 2011
Messages
14,044
What happens if you just use the OutputTo CMD?
 

Momma

Member
Local time
Tomorrow, 04:31
Joined
Jan 22, 2022
Messages
114
What happens if you just use the OutputTo CMD?
It saves the pdf file but the last section of the report is not included but it's there when I run the report.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:31
Joined
Sep 21, 2011
Messages
14,044
Can you run on another computer?, else upload enough for someone else to try.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:31
Joined
May 7, 2009
Messages
19,169
can you show a snapshot of your report including the "last portion"?
 

GPGeorge

Grover Park George
Local time
Today, 10:31
Joined
Nov 25, 2004
Messages
1,776
It saves the pdf file but the last section of the report is not included but it's there when I run the report.
Sometimes it is very helpful to provide details. The "last section" is generic enough to possibly include more than one thing, so it's harder to guess what that problem could be. Show the details if possible, highlighting whatever is not being included.
 

Users who are viewing this thread

Top Bottom