Print Report (1 Viewer)

JPR

Registered User.
Local time
Yesterday, 23:39
Joined
Jan 23, 2009
Messages
192
Hello,

I have created a main report for my db which includes a sub report.

On a form, I have a cmdbutton which converts the report into a pdf file and attaches it to the email.

Depending from the value selected in a combobox, the report may or not include the sub report.

If selection in combo is "A" then the report includes the Subreport. If selection is B, then it does not.

This is the code I have placed in the OnFormat event of report's Detail:

Code:
If Me.myCbo = "A" Then
Me.rptTotal.Visible = True
Me.rptSubPartial.Visible = False
End If

If Me.mycbo = "B" Then
Me.rptTotal.Visible = False
Me.rptSubPartial.Visible = True

End If

The code behind the cmd button which converts the report is the following:

Code:
DoCmd.SendObject acReport, "RptTotal", "PDFFormat(*.pdf)", "", "", "", "Case:" & " " & ME.FNAME & " " & ME.LNAME & " - " & ME.FILENO, "Thank you", True, ""

My problem is that when I select "A" meaning that I want only to include the main report, I still get a blank second page, although the design of them main report fits one page.

Is there a way I can avoid to include in the pdf the second page?

Thank you for your help
 

oleronesoftwares

Passionate Learner
Local time
Yesterday, 23:39
Joined
Sep 22, 2014
Messages
1,159
My problem is that when I select "A" meaning that I want only to include the main report, I still get a blank second page, although the design of them main report fits one page
It is better you have two separate reports.

The report will print a blank second page even if you select A because the second page is a place holder/ section in the main report, so where there is no record, it will still show.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:39
Joined
May 7, 2009
Messages
19,233
you said the Combobox is in a Form?
why on your code it appears to be in the Report?
 

JPR

Registered User.
Local time
Yesterday, 23:39
Joined
Jan 23, 2009
Messages
192
Thank you for your replies. I now understand why it appears on the second page as it is a place holder.
About the code I placed it in the report as not sure how to use it with the send object code.
Is there a way, I could include the second report in the above code? Thank you
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:39
Joined
May 7, 2009
Messages
19,233
another demo for you to see.
you set the Report's SourceObject on the Open event of the Report (main Report).
also, make sure you "adjust" the height of the subreport to "very small".
 

Attachments

  • report_AorB.accdb
    528 KB · Views: 262

JPR

Registered User.
Local time
Yesterday, 23:39
Joined
Jan 23, 2009
Messages
192
Thank you I will give it a try.
 

JPR

Registered User.
Local time
Yesterday, 23:39
Joined
Jan 23, 2009
Messages
192
Hello Arnelgp,

I have tried your db and actually cannot locate where the file is actually stored. After selecting a value from the combo, I cannot see where the report is. Is it because it gets deleted with the code Kill?
Thank you
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:39
Joined
May 7, 2009
Messages
19,233
it is saved in Your Documents.
filename is myReport.pdf
 

JPR

Registered User.
Local time
Yesterday, 23:39
Joined
Jan 23, 2009
Messages
192
Still cannot locate the file. I also tried to rename the path (C:\Documents\myReport.pdf) but just cannot find the file. Sorry about it.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:39
Joined
May 7, 2009
Messages
19,233
Screenshot_8.png
 

JPR

Registered User.
Local time
Yesterday, 23:39
Joined
Jan 23, 2009
Messages
192
Thanks. Obviously I did search in that folder but it is not showing. Very very strange. Don't want to trouble furthermore. No hidden files in the folder.
I have tried it on another standalone PC and works fine. Maybe it has to do with some security settings on my machine as working on a network.
Do you think if I changed the path it would work?
 
Last edited:

JPR

Registered User.
Local time
Yesterday, 23:39
Joined
Jan 23, 2009
Messages
192
found the solutions. I removed the Environ$("userprofile") & code. Working fine now. Thanks
 

Users who are viewing this thread

Top Bottom