msgBox VBA properties - only for the experts out their :o)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like execute a function (doesnt matter wot it is at this time) based
on the selection of a MsgBox.

i.e something like, if the user presses the "O.K" button from the message
box, get access to do something else..

I cant interrogate the properties of the message box to get the value, e.g,
true or false. if "O.K" or "Cancel"

Ive used the screen.activecontrol and screen.previousControl methods, but
they only refer to the controls on the forms that become active after the
message box disspapears.

If anyone cal help, please do!
 
I would like execute a function (doesnt matter wot it is at this time)
based on the selection of a MsgBox.

i.e something like, if the user presses the "O.K" button from the message
box, get access to do something else..

I cant interrogate the properties of the message box to get the value,
e.g, true or false. if "O.K" or "Cancel"

Ive used the screen.activecontrol and screen.previousControl methods, but
they only refer to the controls on the forms that become active after the
message box disspapears.

If anyone cal help, please do!

Two ways to use MsgBox.

MsgBox "..." 'No parenthesis
var = MsgBox("...", ... ) 'Must use parenthesis

The second method assigns the value of the button clicked, e.g. OK or
CANCEL, to the variable.
 
sebastian stephenson said:
I would like execute a function (doesnt matter wot it is at this time)
based
on the selection of a MsgBox.

i.e something like, if the user presses the "O.K" button from the message
box, get access to do something else..

I cant interrogate the properties of the message box to get the value,
e.g,
true or false. if "O.K" or "Cancel"

How about something like

If MsgBox("Do you want to such-and-such?",vbYesNo,"Question") = vbYes Then
Do this
Else
Do that
End If

Keith.
www.keithwilby.com
 
Thanks to you all,

Im working with your suggestions and will post later If Im successful.

Many thanks. I will try Kieths solution first.
 
Two ways to use MsgBox.

MsgBox "..." 'No parenthesis
var = MsgBox("...", ... ) 'Must use parenthesis

The second method assigns the value of the button clicked, e.g. OK or
CANCEL, to the variable.

Test for the value of the constant, e.g. vbOK or vbCANCEL. The way I wrote
it, it appears that you test var against string values of "OK", "CANCEL",
etc... You must test for the numerical value represented by the button
pressed. Examine the Help file against MsgBox function.
 
Back
Top