Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 649
  • Last Modified:

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
    DoCmd.Close
   
    '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.
0
pcsettles
Asked:
pcsettles
1 Solution
 
jjafferrCommented:
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.

jaffer
0
 
jjafferrCommented:
OR

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.

jaffer
0
 
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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

mx
0
 
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?
0
 
jjafferrCommented:
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.


jaffer
0
 
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.
pcsettles
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

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