Report Print event? (1 Viewer)

sja13

Professional Idiot
Local time
Today, 14:40
Joined
May 3, 2017
Messages
63
Hi guys (again!)

I have a pop-up Form which has a command button to print a Report.

When the Report is activated (in Preview mode) I need to hide the Form so the User can see the preview.

My problem is getting the Form visible again when the User “dismisses” the Report, either by printing it or closing it.

Although there is a Report Close event, there doesn’t seem to be a Report Print event in which I can put VBA code to re-display the "invoking" Form.

Can anyone point me in the right direction?
 

Ranman256

Well-known member
Local time
Today, 10:40
Joined
Apr 9, 2015
Messages
4,339
when the preview report shows, the form IS hidden. It is behind the report.
Close the report, you see the form again. Nothing more needs done.
 

sja13

Professional Idiot
Local time
Today, 14:40
Joined
May 3, 2017
Messages
63
No it isn't. That's the part of the problem (see attached).
 

Attachments

  • PrintPreview triggered.jpg
    PrintPreview triggered.jpg
    58.7 KB · Views: 146

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:40
Joined
May 7, 2009
Messages
19,169
after opening the report usind docmd. open report, issue:

Me. Visible=False

then on the Close Event of the report, issue:

[Forms]! yourpopupFormName. Visible=True
 

MarkK

bit cruncher
Local time
Today, 07:40
Joined
Mar 17, 2004
Messages
8,178
You can popup the report if you use acDialog...
Code:
DoCmd.OpenReport "Report1", acViewPreview, , , [COLOR="Blue"]acDialog[/COLOR]
...and then it will appear on top of your popup menu.
hth
Mark
 

sja13

Professional Idiot
Local time
Today, 14:40
Joined
May 3, 2017
Messages
63
OK – firstly thanks to all who took the time to reply.
Special thanks to arnelgp, whose conceptual solution worked just fine.
For the sake of completeness, and in case anyone else wants the full tale, what the actually solution was in my circumstances was as follows:-
I have a number of Reports which are “massaged” by the circumstances in which they are invoked. The modification is for example adding “WHERE” clauses, and/or Sort Order clauses, some of which are picked up using OpenArgs.
So my first attempt was, in the invoking VBA, using
Code:
Public gbooStdReportRequested   As Boolean
in a standard module, then in the Report invocation routine
Code:
  gbooStdReportRequested = True
  DoCmd.OpenReport strReport, _
                   acViewPreview, _
                   , _
                   strWhere, _
                   , _
                   strOpenArgs
  gbooStdReportRequested = False
and in the Reports Close event using
Code:
If gbooStdReportRequested Then
   Forms("frmStdReports").Visible = True
 End If

Oops! – obviously, there’s a synchronisation issue, ‘cos by the time I hit the Print or Close, gbooStdReportRequested was already reset back to False by the Report invocation routine!
So I shifted the flag unsetting to the Report’s Close VBA, and suddenl Robert is your avuncular relative!
Code:
 If gbooStdReportRequested Then
'*
'** Clear the "Invoked by Std Reports" flag.
'*
   gbooStdReportRequested = False
   Forms("frmStdReports").Visible = True
 End If

N.B. As it happens, I used

Code:
   Forms("frmStdReports").Visible = True
Instead of
Code:
  Forms!frmStdReports.Visible = True
Which worked, but the original suggestion may have been just as good: I started fiddling about with the code before I relised the issue was synchronicity, and stopped fiddling when it worked!
 

Users who are viewing this thread

Top Bottom