Make MsgBox non modal?

Posted on 2007-08-02
Last Modified: 2012-06-21
I want to open a report in preview mode via a button on a form, give the user the chance to print the report or not, then open a MsgBox that asks if the report printed ok (printer might be down, wrong paper, etc).  If the answer is 'Yes', then I do an update query on a table.  Following is my code so far:

  stDocName = "rptLetterConfirmation"
  DoCmd.OpenReport stDocName, acPreview, , , acDialog

  Msg = "Confirmation Letters Print Correctly?"    ' Define message.
  Style = vbYesNo + vbDefaultButton2    ' Define buttons.
  Title = "Confirmation Letters"    ' Define title.

  Response = MsgBox(Msg, Style, Title)
  If Response = vbYes Then    ' User chose Yes
    'SQL to fill TchLtr with Date()
    SqlStr = "UPDATE tblOrders SET tblOrders.TchLtr = Date() " & _
              "WHERE (((tblOrders.TchLtr) Is Null));"
    DoCmd.RunSQL SqlStr

The problem is that when the report preview becomes modal the user can't get to a print command. If I make the report preview non-modal, the MsgBox appears and seems to always be modal.   Hence, the user can't get back to the preview report to print it without answering the MsgBox first.  If I could make the MsgBox non-modal, I think I'd be ok.
Question by:pcsettles
    LVL 27

    Accepted Solution

    make your own Form, which looks like your Message box (or so),
    and once it is a Form, you can have any control on it you like.

    LVL 27

    Expert Comment


    On Exit of the Report, make a msgbox appear with your request, and make your code in a module, so it be executed and free the Report from memory.

    LVL 92

    Expert Comment

    by:Patrick Matthews
    I'm pretty sure MsgBox is always modal; looking at the documentation, your only choice is
    between application modal and system modal.

    However, you can use an Access form, which can be modeless, to poll the user.
    LVL 75

    Expert Comment

    by:DatabaseMX (Joe Anderson - Access MVP)
    The message box will either be Application Modal or System Modal ... the only two options, unfortunately.


    Author Comment

    To jjaffer: Ok, I didn't think about doing your first suggestion.  I can do that and it should work fine.  However, I don't fully understand your second suggestion.  I can't figure out how to Exit the Report, and 'then' have the MsgBox appear.  Are you saying that if the MsgBox code is in a module that is called just after the OpenReport, it won't appear until after the Report is Exited?
    LVL 27

    Expert Comment

    Hi pcsettles
    >Ok, I didn't think about doing your first suggestion
    this is where we try to help,
    but why did you give me a B grade :(
    the solution fits your requirment, and you were happy with it, but I know there is No magic or glory in it!!!

    >I don't fully understand your second suggestion
    my mistake, Reports don't have "On Exit", it should be "On Close".
    looking at your requirement,
    you don't need to have the Report open, while the msgbox is open too,
    I would do it in the following way:
    Open the Report in preview mode to allow the user to print or not,
    place your above code as a PUBLIC SUB Printed() in a module,
    "on close" of the Report have a code to quit the Repeort, then to run the SUB Printed,
    so now, the Report is closed, and you have your normal msgbox,
    if the user clicks Yes (remove the docmd.close), then run your SQL,
    if the user clicks No, then you can either print the Report by opening it in a normal mode, OR open the Report Again in preview mode, and go through this cycle again.


    Author Comment

    Hi jjaffer:
    Thanks for your continued interest in my question.  I already took care of the issue by following your first suggestion.  I will attempt your latest comment when I get time to see if it works any better and for my own instruction.  Thanks again for the suggestions.

    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

    Join & Write a Comment

    The first two articles in this short series — Using a Criteria Form to Filter Records ( and Building a Custom Filter ( — discuss in some detail how a form can be…
    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 utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    734 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

    23 Experts available now in Live!

    Get 1:1 Help Now