Make MsgBox non modal?

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.
Who is Participating?
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.


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.

Patrick MatthewsCommented:
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.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

pcsettlesAuthor Commented:
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?
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.

pcsettlesAuthor Commented:
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.
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.