0
votes

I need to print reports embedded in navigation form. I was looking for a solution in the internet and seems like the best one is: https://www.experts-exchange.com/questions/28236835/print-current-report-inside-of-navigation-form-access-2010.html

People claim it works, however, I have a strange problem. This code always prints just one report, even though I have the same code in all of them.

I have modul1

Option Compare Database
Public strpubReportName As String

In all 3 reports and one form I have the same code:

Private Sub Report_GotFocus()
strpubReportName = Me.Name
End Sub

Then the button placed in a navigation form header has:

Private Sub Polecenie20_Click()
    DoCmd.OpenReport strpubReportName
    strprvtReportName = ""
End Sub

And it always prints just one report (not even the report that is displayed on default). No matter which report I open in a navigation form, only one will be printed.

Also why there is this line? This variable is not even created or used in this code, is it the author's mistake? I guess it doesn't matter because changing it to strpubReportName makes no difference.

  strprvtReportName = ""
1

1 Answers

0
votes

I doubt that code could've ever worked.

There are multiple ways to go about achieving this. The most simple, I guess, is to just use a tempvar.

Remove the code from module 1, and replace strprvtReportName with TempVars!strprvtReportName in the other places. That should do it.

As you said, that last line doesn't really have a purpose. You can remove it.