• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1518
  • Last Modified:

Set focus on opne report

I have a form with Popup and Modal set to Yes. I want to be able to double-click a combo box control and open a report in preview mode. The code also sets the focus on a control in the report. When my code executes, the report opens and momentarily has the focus, but the focus then switches back to the form in which the double-click event ran. I have to have my forms remain Modal, so how do I get the report to retain the focus when opening in preview from a modal form?
  • 2
1 Solution
You'll have to set the report to modal as well...

Or open it with the windomode argument set to acDialog.

docmd.OpenReport "rptName", View := acViewPreview, WindowMode:= acDialog

Open in new window

You may also need to set Popup to No on your form - and just leave Modal set to Yes.
Jeffrey CoachmanMIS LiasonCommented:
A bit more info.

The Modal/Popup properties *Prevent* other windows from opening on top of the form.
So as mbizup states, if you want the report to get the focus, turn off the Modal/popup on the form.

In other words, you cannot have a form stay on top all the time, but yet still allow a Report to be on top.

<The code also sets the focus on a control in the report.>
I don't think this is possible in "Print Preview"
You can however do this in "Report View", but the control will display #Name?
...Code to Open a report in Report view:
DoCmd.OpenReport "YourReport", acViewReport
...Then on the Open event of the report do something like this:
But you may have to explain a bit more about this requirement.

paulmcneilAuthor Commented:
Thanks mbizup

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now