Difficulty in printing a report (1 Viewer)

JohnPapa

Registered User.
Local time
Today, 10:49
Joined
Aug 15, 2010
Messages
954
I use the following command to open a report called rptMedicalHistory

DoCmd.OpenReport "rptMedicalHistory", acViewPreview, , , acDialog

from a form that is also open in acDialog mode.

My problem is that once the report is open there is no way to print it, If I do a Control-P I have the option to print to PDF.

In the Ribbon Name of the report I have my report ribbon which does not show up.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:49
Joined
May 7, 2009
Messages
19,248
In the Ribbon Name of the report I have my report ribbon which does not show up.
maybe there are errors when loading your ribbon.
you can Toggle Add-in error msg by going to Option->Client Settings->General->show add-in user interface error.
 

JohnPapa

Registered User.
Local time
Today, 10:49
Joined
Aug 15, 2010
Messages
954
Have tried your suggestion. No result.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:49
Joined
May 7, 2009
Messages
19,248
did you close and re-open it again?
if there is no error then your Ribbon has no error.
 

JohnPapa

Registered User.
Local time
Today, 10:49
Joined
Aug 15, 2010
Messages
954
As I mentioned, I can output to PDF and print the PDF, but this is not user friendly.
did you close and re-open it again?
if there is no error then your Ribbon has no error.
Yes I reopened.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:49
Joined
May 7, 2009
Messages
19,248
As I mentioned, I can output to PDF and print the PDF, but this is not user friendly.
if you have Installed a printer then your printer will show up when you press Ctrl-P.
 

JohnPapa

Registered User.
Local time
Today, 10:49
Joined
Aug 15, 2010
Messages
954
You are right. The pc which I tested it is not connected to a printer.

Is there a way to show Control P somehow, making it more user friendly.
 

LarryE

Active member
Local time
Today, 00:49
Joined
Aug 18, 2021
Messages
592
You can use:
Application.CommandBars.ExecuteMso ("PrintDialogAccess")
to expose and open the system Print Dialog to select printers
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:49
Joined
May 7, 2009
Messages
19,248
Is there a way to show Control P somehow, making it more user friendly.
you should first investigate why your ribbon is not showing.
maybe you already have the "Print" button there.
 

JohnPapa

Registered User.
Local time
Today, 10:49
Joined
Aug 15, 2010
Messages
954
You can use:
Application.CommandBars.ExecuteMso ("PrintDialogAccess")
to expose and open the system Print Dialog to select printers
Your suggestion works as you indicate, but does not help in my case since my report opens in acDialog mode
 

JohnPapa

Registered User.
Local time
Today, 10:49
Joined
Aug 15, 2010
Messages
954
Your suggestion works as you indicate, but does not help in my case since my report opens in acDialog mode
If I remove the acDialog parameter when opening the report, the report opens behind the form which called the report (The form is opened in acDialog) and I get the prompt for printing which prints the report, which does not show on the screen. It is behind the open form.

Is there a way to bring this report (when opened without acDialog) to the foreground? I tried setting the Focus to the report without success.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:49
Joined
May 7, 2009
Messages
19,248
you may have "other" code After you opened the Report so it is losing focus when you open it.
add another code, after all code have run to SetFocus on the Report.

docmd.SelectObject acReport,"theReportNameHere",False
 

JohnPapa

Registered User.
Local time
Today, 10:49
Joined
Aug 15, 2010
Messages
954
you may have "other" code After you opened the Report so it is losing focus when you open it.
add another code, after all code have run to SetFocus on the Report.

docmd.SelectObject acReport,"theReportNameHere",False
Did not work. Still in the background behind the forms.

These are the last 2 lines of code in the sub

DoCmd.OpenReport "rptMedicalHistoryTabularNew", acViewPreview
DoCmd.SelectObject acReport, "rptMedicalHistoryTabularNew", False
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:49
Joined
Feb 19, 2013
Messages
16,622
Your suggestion works as you indicate, but does not help in my case since my report opens in acDialog mode

Remove from your openreport parameters and in the report properties set popup and modal to true

in the report open event put the code

me.modal=false

so what should happen is the report opens on top because of the modal. But modal prevents changing focus to elsewhere (as acdialog does). Setting modal to false should enable you to access the print dialog
 

JohnPapa

Registered User.
Local time
Today, 10:49
Joined
Aug 15, 2010
Messages
954
Remove from your openreport parameters and in the report properties set popup and modal to true

in the report open event put the code

me.modal=false

so what should happen is the report opens on top because of the modal. But modal prevents changing focus to elsewhere (as acdialog does). Setting modal to false should enable you to access the print dialog
The last statement in the form button click is
DoCmd.OpenReport "rptMedicalHistoryTabularNew", acViewPreview

In the report properties I set popup and modal to yes

In the Report Open I placed me.modal = false

The report opens on top, as in the case of using acDialog and the only way to print is to use Control-P

The report ribbon does not appear.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:49
Joined
May 7, 2009
Messages
19,248
The report ribbon does not appear.
it will if your ribbon is "well" formed.
you can always upload your db for troubleshooting.
since going further we can only do wild guess.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:49
Joined
Feb 19, 2013
Messages
16,622
I was suggesting you use
Application.CommandBars.ExecuteMso ("PrintDialogAccess")

as previously suggested
probably also in the report open event
 

JohnPapa

Registered User.
Local time
Today, 10:49
Joined
Aug 15, 2010
Messages
954
Thanks, I put also command
Application.CommandBars.ExecuteMso ("PrintDialogAccess")

and it prompts to print. A step forward. Thanks
 

JohnPapa

Registered User.
Local time
Today, 10:49
Joined
Aug 15, 2010
Messages
954
it will if your ribbon is "well" formed.
you can always upload your db for troubleshooting.
since going further we can only do wild guess.
The ribbon appears if I do not use acDialog when opening the report.

The ribbon also appears in other reports and it is being used for 20 years. The FE db is about 200Mb.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:49
Joined
May 7, 2009
Messages
19,248
and it prompts to print. A step forward. Thanks
the Question now is "what" will it print?
if you open the Report via a button on a Form, the Form will get printed Not the report.
 

Users who are viewing this thread

Top Bottom