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

Momma

Member
Local time
Tomorrow, 00:16
Joined
Jan 22, 2022
Messages
70
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, 15:16
Joined
Sep 21, 2011
Messages
10,850
What happens if you just use the OutputTo CMD?
 

Momma

Member
Local time
Tomorrow, 00:16
Joined
Jan 22, 2022
Messages
70
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, 15:16
Joined
Sep 21, 2011
Messages
10,850
Can you run on another computer?, else upload enough for someone else to try.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:16
Joined
May 7, 2009
Messages
16,810
can you show a snapshot of your report including the "last portion"?
 

GPGeorge

Grover Park George
Local time
Today, 07:16
Joined
Nov 25, 2004
Messages
769
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