Why report preview appearing behind an open form?

I have a report preview that when opens appears BEHIND an open form.  If I click on the report it comes to the front.  Why would this be happening and can I make it open in front of the open form?
SteveL13Asked:
Who is Participating?
 
mbizupConnect With a Mentor Commented:
<< I have a report preview that when opens appears BEHIND an open form. >>
<< Both popup and modal are false. >>

Opening a report from a form will by default make the report appear on top of the form as you are looking for.  (The report shown on top is *normal* behavior)

<< Why would this be happening >>

There are a couple of factors that might cause the form to show up on top instead of the report.
1.  The form will display on top if it's popup property is true or if it was opened with acDialog window mode.

2. If the code executing in your form refers back to the form or a control on the form after your OpenReport command, it will bring the form back into focus and make the form appear on top of the report.

Based on the code in your recent questions, factor #2 is at work (see the inline comment):

Case 3        
DoCmd.OpenReport "rptOpenReturns", acViewPreview
Reports!rptOpenReturns.lblAllRMAStatus.Visible = True
Me.Frame21 = Null '******** This will bring the form to the top ******

Open in new window


Opening the report with acDialog, as cap1 mentioned will force the report to the top.  However, it will also suspend the code execution until the report closes, which will cause the second line of code to error after the report is closed.

So your options are to use acDialog and move the second line of code to your report's Detail Format event, OR  rewrite the code that opens your report so that the form reference comes before the OpenReport command, like this:

Case 3       
Me.Frame21 = Null
DoCmd.OpenReport "rptOpenReturns", acViewPreview
Reports!rptOpenReturns.lblAllRMAStatus.Visible = True

Open in new window

0
 
gplanaCommented:
Check the popup property on your form. If it is set, then the form will be above. You should set it to false (and also the modal property too).

Hope it helps.
0
 
SteveL13Author Commented:
Both popup and modal are false.
0
 
Rey Obrero (Capricorn1)Commented:
change the code that open the report, with the option acdialog

like this

DoCmd.OpenReport "ReportName", acViewPreview, Windowmode:=acDialog
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.