Access prints the form instead of the report called from the form

caere

New member
Local time
Today, 17:48
Joined
Jul 8, 2009
Messages
5
ecblank.gif
ecblank.gif
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
 
To print a report from a form I will generally NOT use the procedure you are using.

The report is controlled from a query with the criteria being:
[Forms]![YourFormName]![CLIENTE]

This will lock the report to the record you currently have displayed on your form.
 
Thanks statsman for your comment. That is OK because I need a report for a specific record, unless the locking of the report to a specific record displayed on the form is responsible for the printing of the form instead of the report, and this is my main problem now.
 
caere,

If you are wanting to have your report show in preview mode and then be able to print it, all you need to do is to make sure the you have the Preview of the report selected and then use the Print option from the menu for that report. That will print the report. I thing you are having the form as the object selected and that is why you are having the form printed.

If, however, you just want the report to go ahead and print, change the line:
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
to
DoCmd.OpenReport stDocName, acViewNormal, , stLinkCriteria

This will just print the report with no preview.
 
Thanks Mr. B for your reply. I already know I can change the AC in the command and that the report should have the focus. That worked that way up to when suddenly things changed without modifications of the application and its reports. The same problem happened with other Access apps. So, what I suspect is that probably some automatic update of Access or the framework are resposnsible for this behavior.
Does anybody know anything about that?
By the way, my Access version is 2003 with SP 3. I tried to disinstall and reinstall Access just with SP2 but nothing changed.
Thanks in advance.
 

Users who are viewing this thread

Back
Top Bottom