Printing problem

P

Paradigm

I have a number of reports and I use a cutomised toolbar with a button with
a function: -

Function printit()
On Error Resume Next
DoCmd.RunCommand acCmdPrint
End Function

I also use another function to hide all open forms when the report is opened
so that the user can only see the report until he closes it at which point a
third function unhides the forms.

The problem is this.
Every so often (and this varies with computer some more than others and some
almost every time) even though only the report is visible on the screen as
it should be, the printed report shows the underlying form and not the
report.

I cannot find a solution to this. Since I use the same toolbar for all the
reports, I do not want to have to code the report name into it since I would
then need a number of toolbars, one for each report.

Alec
 
V

Van T. Dinh

It sounds like due to different timing, the Focus is returned to the Form
rather than the Report.

If you only open 1 Report, use the Reports Collection to get the name of the
Report and the SelectObject Method to make sure the Report has the Focus
before acCmdPrint.
 
P

Paradigm

The report is opened first in preview mode and the DoCmd.RunCommand
acCmdPrint
is used so that the user can select a printer before printing.
If I get the name of the open report how can I then print this and let the
user select a printer.
Alec
 
V

Van T. Dinh

Once you have the name of the Report, you can use SelectObject Method to
make the Report the ActiveReport then you can use the RunCommand acCmdPrint
to print the ActiveReport.
 
P

Paradigm

Thanks
That works.
Alec

Van T. Dinh said:
Once you have the name of the Report, you can use SelectObject Method to
make the Report the ActiveReport then you can use the RunCommand acCmdPrint
to print the ActiveReport.
 
Top