Access prints the form from wich the report is launch intead of th

M

michelangelo

When I click on a button on a form to launch a report, the report is shown in
preview mode, when I try to print it through file/print what I get printed is
the form not the report, if I ask to print a second report i get the previous
report printed or I'm asked to enter a parameter (f.e. the year) necessary to
filter the report, even though I Have already entered.
This problem also affects old reports that were working OK, and from some
time to now are doing it well.

Here is the code behind the button:

"Private Sub Comando119_Click()
On Error GoTo Err_Comando119_Click

Dim stDocName As String

stDocName = "RESOCONTO singolo"
stLinkCriteria = "[CLIENTE]=" & "'" & Me![CLIENTE] & "'"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Exit_Comando119_Click:
Exit Sub

Err_Comando119_Click:
MsgBox Err.Description
Resume Exit_Comando119_Click

End Sub"

Thanks in advance
 
K

Klatuu

First, the report is coming up in preview mode because the code tells it to.

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
^
This argument tells it open in Preview |

To send it to the printer, use acViewNormal
DoCmd.OpenReport stDocName, acViewNormal, , stLinkCriteria

The reason it is printing the form is because you are using File Print and
the Active Window is the form. To print a report you have open in Preview is
to rigth click and you will get a menu with one of the options being Print.

(funny how those computers always do what you tell them rather than what you
want them to do)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top