Solved Report display inconsistency (1 Viewer)

PaquettePaul

Member
Local time
Today, 16:04
Joined
Mar 28, 2022
Messages
107
Common subroutine that displays, prints, and create PDF files For different reports

gblReportSelection “rptEventInvoice”
gblFilter = “EventPK = “ & Me!cmbInvoices

Case 1 ‘print preview
DoCmd.OpenReport gblReportSelection, acViewPreview
Case 2 ‘send to printer
DoCmd.OpenReport gblReportSelection, acViewNormal
Case 3 ‘create PDF file
gblText = gblDirectoryPath & ”\” & ”stFileName & “.pdf”
DoCmd.OutputTo acOutputReport, gblReportSelection, acFormatPDF, gblText

when I select an Invoice to report and then select Case 1, I see a print preview of the requested invoice. When I select Case 2 or Case 3, it ignores the invoice key and only prints the the last invoice on file.

suggestions as to what I am doing wrong. I would think that the report would work the same regardless of the output method.
 

PaquettePaul

Member
Local time
Today, 16:04
Joined
Mar 28, 2022
Messages
107
The filter is not being set properly. Will need to work on it further
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:04
Joined
Aug 30, 2003
Messages
36,126
I would expect 1 and 2 to do the same thing. I don't see where you use the filter. I'd expect it in the wherecondition argument, shown here for OpenForm:


For 3, you'd need to open the report filtered in preview mode, output the file, then close the preview. You can open it hidden so the user doesn't see it opening.
 

PaquettePaul

Member
Local time
Today, 16:04
Joined
Mar 28, 2022
Messages
107
My mistake was setting the report filter in the OnLoad event rather than the OnOpen event. Works fine now. Thanks.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:04
Joined
Aug 30, 2003
Messages
36,126
Glad you got it sorted out.
 

Users who are viewing this thread

Top Bottom