Set focus on opne report

Posted on 2012-09-05
Last Modified: 2012-09-06
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?
Question by:paulmcneil
    LVL 61

    Accepted 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

    LVL 61

    Expert Comment

    You may also need to set Popup to No on your form - and just leave Modal set to Yes.
    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    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.


    Author Closing Comment

    Thanks mbizup

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now