MsgBox Style

alireza1989@hot

Registered User.
Local time
Yesterday, 19:55
Joined
Feb 26, 2007
Messages
23
I just wanted to ask how to change the msgbox style, for example, put a Critical or Information picture on the side of the message box

Thanx in advance
 
MsgBox "Your Message Here",vbinformation
will give you the yellow exclamation

MsgBox "Your Message Here", vbCritical
will give you the red x mark
 
have a look at the MsgBox Function in Access help. You will require constants such as 16, 32, 48 or 64 to obtain critical, information, etc icons on the message

Dave
 
MsgBox "Your Message Here",vbinformation
will give you the yellow exclamation

MsgBox "Your Message Here", vbCritical
will give you the red x mark

And vbQuestion for the question mark in the baloon.
 
have a look at the MsgBox Function in Access help. You will require constants such as 16, 32, 48 or 64 to obtain critical, information, etc icons on the message

Dave

MsgBox("Is the information" & vbCrLf & " CORRECT?", vbYesNo Or _
vbQuestion Or vbDefaultButton1, "Verify Information and Save")

As an example, I use this to verify information before a complete autofill on a form. It could use the vbInformation, or vbCritical, or vbExclamation and all would (and have) included the appropriate icon on the msgbox. I'm not sure I follow.
 
Code:
If Msgbox("Is the information" & VbCrLf & "Correct?", VbQuestion + VbYesNo + vbDefaultButton1, "Verify Information and Save") = vbYes Then 
 ...put code if yes here
Else
...put code if no here
End If

If you want to apply multiple types to the message box, add them in with the plus (+) sign. If you need to know which button was selected, you can assign it to something like this:
Code:
Dim varResp As Variant

varResp = Msgbox("Is the information" & VbCrLf & "Correct?", VbQuestion + VbYesNoCancel + vbDefaultButton1, "Verify Information and Save") 

Select Case varResp
Case vbYes 
   ...put code here if yes selected
Case vbNo
   ...put code here if no selected
Case vbCancel
   ...put code here if cancel selected
End Select
 
Actually, this msgbox is set up with a Case Statement. I have an If before it and Case statements afterward. I just included a snippet of it here to illustrate for Dave that I don't need to "... require constants such as 16, 32, 48 or 64 to obtain critical, information, etc icons on the message"

Maybe you can answer that question, Bob. I don't (and have never had to) add 16, 32, 64, ect. to include icons on my msgboxes.
 
You are correct Wiz. As I showed you can add the icons just by using

vbQuestion (if used alone it gives you an ok button only)

vbQuestion + vbYesNo (if used gives you a question icon with yes/no buttons)

vbQuestion + vbYesNoCancel (if used gives you a question icon with yes/no/cancel buttons)

vbCritical + vbAbortRetryIgnore (gives you a dialog with the Critical X and the buttons of vbAbortRetryIgnore)

it's all in what you specifiy with these EASY TO REMEMBER constants (they pop up when using intellisense and you can just concatenate them together with plus signs). Then, you can do the check for their value by using code like what I wrote in my last post.
 
You are correct Wiz. As I showed you can add the icons just by using

vbQuestion (if used alone it gives you an ok button only)

vbQuestion + vbYesNo (if used gives you a question icon with yes/no buttons)

vbQuestion + vbYesNoCancel (if used gives you a question icon with yes/no/cancel buttons)

vbCritical + vbAbortRetryIgnore (gives you a dialog with the Critical X and the buttons of vbAbortRetryIgnore)

it's all in what you specifiy with these EASY TO REMEMBER constants (they pop up when using intellisense and you can just concatenate them together with plus signs). Then, you can do the check for their value by using code like what I wrote in my last post.

Okay, that answers my question - thanks.
 
Just to clarify:

Constants (vbQuestion, etc) are relatively new to VBA (last 5 years?). Before that you had to use values (eg. 16, 32, etc). These constants are now specified by VBA. As a result, the names can be used anywhere in your code in place of the actual values.

Dave (the old timer)
 
Just to clarify:

Constants (vbQuestion, etc) are relatively new to VBA (last 5 years?). Before that you had to use values (eg. 16, 32, etc). These constants are now specified by VBA. As a result, the names can be used anywhere in your code in place of the actual values.

Dave (the old timer)

Thanks for the clarification, Dave - I'm also one of those "programming oldtimers" - but relatively new to Access and VBA.
 

Users who are viewing this thread

Back
Top Bottom