yes/no msg box

bacardi451

Registered User.
Local time
Today, 12:35
Joined
Mar 20, 2002
Messages
33
Hello,
I did a search on this topic but with no avail. I have a command button that is used to email a report. I would like to add a yes or no msg box to that command button. when the user click on the command button I want the msg box to ask if they are sure that they want to send an email report. If they select yes it will continue thru the buttons command process but if the select no the command gets canceled and they are returned to the form.

Thanks in advance
Al:)
 
Last edited:
Try something along these lines:

cmdButton_OnClick()

Dim Response as Integer

Response = MsgBox("Do you wish to continue?", vbYesNo, "E-mail Report")

If Response = vbNo Then 'User chose no
Exit Sub
Else 'User chose yes
etc.
etc.
End If
 
As I am no programmer so I cannot give exact instructions, but I would do it something like this:

I would have the first button send to a form which asks if they are sure that the want to send the report, then the button on that form would be the one that sends the email.

(I use something like this for closing down my database where it ask if they are sure).

I know its not using message boxes, I do not know if you can have a button in a message box. If so then just substitute the message box instead of the form.

Hope this helps a little.
 
Robert Dunstan said:
Try something along these lines:

cmdButton_OnClick()

Dim Response as Integer

Response = MsgBox("Do you wish to continue?", vbYesNo, "E-mail Report")

If Response = vbNo Then 'User chose no
Exit Sub
Else 'User chose yes
etc.
etc.
End If

Thanks that work great.

Al
 
I use a public function:

Code:
Public Function Confirm(StrMessage As String) As Boolean
Dim BytChoice As Byte
BytChoice = MsgBox(StrMessage, vbQuestion + vbYesNo + vbDefaultButton2, conAppName)
If BytChoice = vbYes Then
Confirm = True
Else
Confirm = False
End If
End Function

then call it from ANY form or report as per:

Code:
If Confirm("Do you want to continue?") Then

Cuts down on typing and human error possibilities anyways
 
Glad I could help!

However I would go with Ian's suggestion. It's far better to create a public function to display your msgbox. This means that you can call it from any form etc.
 

Users who are viewing this thread

Back
Top Bottom