Can I close a MsgBox with VBA Code? Something like:
If IsOpen (MsgBox, "Title") Then
Close(MsgBox, "Title")
Run some code
Else
Run other code
End If
Can this be done in VBA? Do I need to work with an API function?
Thanks in advance. 7 110286
No, because the message box is "modal" and stops code execution. It is
almost trivially easy to create your own form that works similar to a
message box, but has a timer, and can close itself.
Larry Linson
Microsoft Access MVP
"deko" <de**@hotmail.com> wrote in message
news:FL******************@newssvr27.news.prodigy.c om... Can I close a MsgBox with VBA Code? Something like:
If IsOpen (MsgBox, "Title") Then Close(MsgBox, "Title") Run some code Else Run other code End If
Can this be done in VBA? Do I need to work with an API function?
Thanks in advance.
> No, because the message box is "modal" and stops code execution. It is almost trivially easy to create your own form that works similar to a message box, but has a timer, and can close itself.
10-4 - I created my own form and it works fine. Thanks for the tip.
deko wrote: Can I close a MsgBox with VBA Code? Something like:
If IsOpen (MsgBox, "Title") Then Close(MsgBox, "Title") Run some code Else Run other code End If
Can this be done in VBA?
Actually, yes. I put a command button on a form that when pressed will
display a message box. The message box will be closed in 5 seconds.
Option Compare Database
Option Explicit
Private Sub Command0_Click()
Me.TimerInterval = 5000
MsgBox "Hello. I will go bye-bye in 5 seconds."
Me.TimerInterval = 0
End Sub
Private Sub Form_Timer()
'you could use "{Esc}" here
SendKeys "{Enter}"
End Sub
What about a multiple button msgbox?
Option Compare Database
Option Explicit
Private Sub Command0_Click()
Dim var As Variant
Me.TimerInterval = 5000
'if nothing is pressed on multiple button msgboxes
'then default button is selected. You can get around
'this with a flag setting...ex in OnTimer set a flag
'to true (or false) that determines if Timer closed
'the msgbox or if the user did.
var = MsgBox("Hello", vbYesNo, "Hi")
Me.TimerInterval = 0
MsgBox (var = vbYes)
End Sub
Private Sub Form_Timer()
'can't use "{Esc}" with multiple button options
SendKeys "{Enter}"
End Sub
Salad <oi*@vinegar.com> wrote in news:UGggc.14973$k05.3379
@newsread2.news.pas.earthlink.net: deko wrote:
Can I close a MsgBox with VBA Code? Something like:
If IsOpen (MsgBox, "Title") Then Close(MsgBox, "Title") Run some code Else Run other code End If
Can this be done in VBA?
Actually, yes. I put a command button on a form that when pressed will display a message box. The message box will be closed in 5 seconds.
Option Compare Database Option Explicit Private Sub Command0_Click() Me.TimerInterval = 5000 MsgBox "Hello. I will go bye-bye in 5 seconds." Me.TimerInterval = 0 End Sub Private Sub Form_Timer() 'you could use "{Esc}" here SendKeys "{Enter}" End Sub
What about a multiple button msgbox?
Option Compare Database Option Explicit Private Sub Command0_Click() Dim var As Variant Me.TimerInterval = 5000 'if nothing is pressed on multiple button msgboxes 'then default button is selected. You can get around 'this with a flag setting...ex in OnTimer set a flag 'to true (or false) that determines if Timer closed 'the msgbox or if the user did. var = MsgBox("Hello", vbYesNo, "Hi") Me.TimerInterval = 0 MsgBox (var = vbYes) End Sub Private Sub Form_Timer() 'can't use "{Esc}" with multiple button options SendKeys "{Enter}" End Sub
sigh ...
--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Lyle Fairfield wrote: Salad <oi*@vinegar.com> wrote in news:UGggc.14973$k05.3379 @newsread2.news.pas.earthlink.net:
deko wrote:
Can I close a MsgBox with VBA Code? Something like:
If IsOpen (MsgBox, "Title") Then Close(MsgBox, "Title") Run some code Else Run other code End If
Can this be done in VBA?
Actually, yes. I put a command button on a form that when pressed will display a message box. The message box will be closed in 5 seconds.
Option Compare Database Option Explicit Private Sub Command0_Click() Me.TimerInterval = 5000 MsgBox "Hello. I will go bye-bye in 5 seconds." Me.TimerInterval = 0 End Sub Private Sub Form_Timer() 'you could use "{Esc}" here SendKeys "{Enter}" End Sub
What about a multiple button msgbox?
Option Compare Database Option Explicit Private Sub Command0_Click() Dim var As Variant Me.TimerInterval = 5000 'if nothing is pressed on multiple button msgboxes 'then default button is selected. You can get around 'this with a flag setting...ex in OnTimer set a flag 'to true (or false) that determines if Timer closed 'the msgbox or if the user did. var = MsgBox("Hello", vbYesNo, "Hi") Me.TimerInterval = 0 MsgBox (var = vbYes) End Sub Private Sub Form_Timer() 'can't use "{Esc}" with multiple button options SendKeys "{Enter}" End Sub
sigh ...
Why sigh?
Salad wrote: Lyle Fairfield wrote:
Salad <oi*@vinegar.com> wrote in news:UGggc.14973$k05.3379 @newsread2.news.pas.earthlink.net:
deko wrote:
Can I close a MsgBox with VBA Code? Something like:
If IsOpen (MsgBox, "Title") Then Close(MsgBox, "Title") Run some code Else Run other code End If
Can this be done in VBA?
Actually, yes. I put a command button on a form that when pressed will display a message box. The message box will be closed in 5 seconds.
Option Compare Database Option Explicit Private Sub Command0_Click() Me.TimerInterval = 5000 MsgBox "Hello. I will go bye-bye in 5 seconds." Me.TimerInterval = 0 End Sub Private Sub Form_Timer() 'you could use "{Esc}" here SendKeys "{Enter}" End Sub
What about a multiple button msgbox?
Option Compare Database Option Explicit Private Sub Command0_Click() Dim var As Variant Me.TimerInterval = 5000 'if nothing is pressed on multiple button msgboxes 'then default button is selected. You can get around 'this with a flag setting...ex in OnTimer set a flag 'to true (or false) that determines if Timer closed 'the msgbox or if the user did. var = MsgBox("Hello", vbYesNo, "Hi") Me.TimerInterval = 0 MsgBox (var = vbYes) End Sub Private Sub Form_Timer() 'can't use "{Esc}" with multiple button options SendKeys "{Enter}" End Sub sigh ...
Why sigh?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
SendKeys, bad joojoo.
When the MsgBox is open the user can set the focus on another
application. What if the SendKeys occurs when the focus is on a Format
dialog box and the focus is on the "Do you really want to do this"
button and the drive to be formatted is C:? Time elapses SendKeys sends
{Enter} & format commences. Yikes!
I know far-fetched, but you know users - unpredictable creatures: "Hey,
I wonder what this does?".
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQIQ1tYechKqOuFEgEQKxUgCeJThrwV+AJ6+bvesToBx1r9 ID7PEAnjyE
BHNQR94g0yODzCSrqfG3r1eg
=WTwr
-----END PGP SIGNATURE-----
MGFoster wrote: SendKeys, bad joojoo.
When the MsgBox is open the user can set the focus on another application. What if the SendKeys occurs when the focus is on a Format dialog box and the focus is on the "Do you really want to do this" button and the drive to be formatted is C:? Time elapses SendKeys sends {Enter} & format commences. Yikes!
LOL I know far-fetched, but you know users - unpredictable creatures: "Hey, I wonder what this does?".
They ask questions for trivial matters but never ask during crucial matters.
Thanks for the update. I don't think I have any users that are as swift
as the ones you describe up above <g> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: deko |
last post by:
Can I close a MsgBox with VBA Code? Something like:
If IsOpen (MsgBox, "Title") Then
Close(MsgBox, "Title")
Run some code
Else
Run other code
End If
Can this be done in VBA? Do I need to...
|
by: Ronny Sigo |
last post by:
Hello all,
I have made a button in access which opens iexplore and directs it to a
certain website.
I have use a piece of code written by Dev Ashish. So far so good. But now I
need to know how I...
|
by: Pierke |
last post by:
Hey guys out there,
I really need your help, i am building up a web site, so
for security reasons i need to do "some things" before the
user log off, and i indeed do it. Now the matter is that...
|
by: mg |
last post by:
Once opening WebForm2 from WebForm1 using
Response.Write("<script language='javascript'>window.open
('WebForm2.aspx','two','menubar=no');</script>");
how can I close WebForm1?
|
by: Bruce Wiebe |
last post by:
hi all
im having a problem accessing a text file on my hard disk after ive
created it and added some text to it it would appear that the file is
still locked.
What happens is this i have...
|
by: Valerie Hough |
last post by:
I would like to be able to determine if a given folder is open on a user's
desktop, and be able to close it. Is this possible?
Thanks in advance,
Valerie Hough
|
by: Frank Rizzo |
last post by:
I am trying to programmatically close a messagebox. I don't see any
obvious managed choices. Back in the day, I remember using a
combination of FindWindow and EndDialog apis(...
|
by: dummy07 |
last post by:
Is it possible to close a modal window from the parent window???
Please help..
|
by: sneha9 |
last post by:
hi all,
Please let me know if we can close the dialogbox opened by some other program on windows, i mean if am putting automation scripts for run and inbetween if the program fails due to some...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |