Non code interrupting msgbox

P

Peter-d

Does anyone know if there is a way to display a message to a db user that
will not halt the code from running until the user dismisses the message as
the regular message box does?

Some back ground, I've built in my application the ability to shut it down
remotely based on a value in a table (the value is looked up from the timer
event of my switchboard), so while I wait for all instances to shut down, I
don't want others to start the db... so on the load event of the same switch
board, I lookup a different value in a table (DBEnabled for example) and have
code such as:

If bDBEnabled = False then
msgbox "The database is currently unavailble ..."
Application.Quit
end if

But if the user decides to not click the ok button, then access remains
opened and the database stays locked... so I can't open it exclusively and
perform the needed changes.

Thanks for any feedback/direction you can give me
Peter-d
 
D

Dirk Goldgar

Peter-d said:
Does anyone know if there is a way to display a message to a db user
that will not halt the code from running until the user dismisses the
message as the regular message box does?

Some back ground, I've built in my application the ability to shut it
down remotely based on a value in a table (the value is looked up
from the timer event of my switchboard), so while I wait for all
instances to shut down, I don't want others to start the db... so on
the load event of the same switch board, I lookup a different value
in a table (DBEnabled for example) and have code such as:

If bDBEnabled = False then
msgbox "The database is currently unavailble ..."
Application.Quit
end if

But if the user decides to not click the ok button, then access
remains opened and the database stays locked... so I can't open it
exclusively and perform the needed changes.

Thanks for any feedback/direction you can give me
Peter-d

You can build and display your own message form. You can even make it a
popup form. So long as you don't open it in dialog mode, it won't halt
the running code.
 
P

Peter-d

Thanks for the suggestion...
However, the point of what I'm tring to accomplish is that the database
would be shudown (and lock released) before the user acknowledges the message.

I suppose I could display a form as you suggested and keep it visible for
only x seconds before shutting it down.

One other way I though, but found it too cumbersome would be to have a vb
script file somewhere that would contain a msgbox statement and I could just
shell out to this vbs.
 
P

Peter-d

Well, I didn't relaly want to... but unless someone has something else to
suggest, here is what I've done...

I've created the following sub:

Sub DisplayVBSMsgBox(Prompt As String, Optional Buttons As VbMsgBoxStyle =
0, Optional Title As String = "")
Shell "CSCRIPT """ & CurrentProject.Path & "\vbs_msgbox.vbs"" """ &
Replace(Prompt, vbCr, "||") & """ " & Buttons & " """ & Title & """", vbHide
End Sub

And I put teh file vbs_msgbox.vbs in same folder as my application with only
one line of code:
msgbox replace(WScript.Arguments.Item(0), "||", vbcr),
WScript.Arguments.Item(1), WScript.Arguments.Item(2)

Notice how I replaced potential carriage return in my original prompt sting
with a unique symbole combination (|| in my case) and then replaced them back
with vbcr in the vbs. I'm not sure if this is the best apporach tho.

Seems to work for now... but I'd love to not have to deal with this .vbs file.
 
D

Dirk Goldgar

Peter-d said:
Thanks for the suggestion...
However, the point of what I'm tring to accomplish is that the
database
would be shudown (and lock released) before the user acknowledges the
message.

I suppose I could display a form as you suggested and keep it visible
for only x seconds before shutting it down.

I'm not sure I understand what the problem is. You can open a form and
leave it open until the closing of the database closes it automatically,
with out the user ever taking any action.
 
P

Peter-d

Dirk Goldgar said:
I'm not sure I understand what the problem is. You can open a form and
leave it open until the closing of the database closes it automatically,
with out the user ever taking any action.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

This is true, however, if I want the database to close immediately after the
form loads, I think the user would not have a chance to even read the message
displayed on the form before it would be closed along with the database.
 
D

Dirk Goldgar

Peter-d said:
This is true, however, if I want the database to close immediately
after the form loads, I think the user would not have a chance to
even read the message displayed on the form before it would be closed
along with the database.

Then I'm not sure what you want to have happen. How long would you want
the message to be displayed? You can use the form's Timer event to
close it, and quit Access, after a certain period of time.
 
Top