Message Box

L

Luther

Hi,

How would I put a message box that would give me both [OK]
and [CANCEL] buttons so the user can choose not to run
that particular function if they choose. I have set the
warnings off and wanted to put my own message. Any ideas,
please? By the way, this function calls for a query to run.
 
G

Gerald Stanley

Try something along the lines of

If MsgBox("Do You Want to Run The Query", vbOkCancel) =
vbOk Then
code to run the query
End If

Hope This Helps
Gerald Stanley MCSD
 
G

Guest

Thanks a lot, Gerald. Am I to assume that, by default, if
you specify some action for OK, then Cancel will have the
opposite and abort the process?
-----Original Message-----
Try something along the lines of

If MsgBox("Do You Want to Run The Query", vbOkCancel) =
vbOk Then
code to run the query
End If

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
Hi,

How would I put a message box that would give me both [OK]
and [CANCEL] buttons so the user can choose not to run
that particular function if they choose. I have set the
warnings off and wanted to put my own message. Any ideas,
please? By the way, this function calls for a query to run.
.
.
 
G

Gerald Stanley

As the 2nd parameter into the Msgbox function specifies
only two buttons (Ok and Cancel), you can use a standard If
Then Else construct to code for either button being
clicked. So, if there is specific actions that you wish to
follow if the Cancel button is clicked, the code would look
like
If MsgBox("Do You Want to Run The Query", vbOkCancel) =
vbOk Then
code to run the query
Else
code to cancel the action
End If

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
Thanks a lot, Gerald. Am I to assume that, by default, if
you specify some action for OK, then Cancel will have the
opposite and abort the process?
-----Original Message-----
Try something along the lines of

If MsgBox("Do You Want to Run The Query", vbOkCancel) =
vbOk Then
code to run the query
End If

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
Hi,

How would I put a message box that would give me both [OK]
and [CANCEL] buttons so the user can choose not to run
that particular function if they choose. I have set the
warnings off and wanted to put my own message. Any ideas,
please? By the way, this function calls for a query to run.
.
.
.
 
G

Guest

Thank you, Gerald. Most helpful.
-----Original Message-----
As the 2nd parameter into the Msgbox function specifies
only two buttons (Ok and Cancel), you can use a standard If
Then Else construct to code for either button being
clicked. So, if there is specific actions that you wish to
follow if the Cancel button is clicked, the code would look
like
If MsgBox("Do You Want to Run The Query", vbOkCancel) =
vbOk Then
code to run the query
Else
code to cancel the action
End If

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
Thanks a lot, Gerald. Am I to assume that, by default, if
you specify some action for OK, then Cancel will have the
opposite and abort the process?
-----Original Message-----
Try something along the lines of

If MsgBox("Do You Want to Run The Query", vbOkCancel) =
vbOk Then
code to run the query
End If

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
Hi,

How would I put a message box that would give me both [OK]
and [CANCEL] buttons so the user can choose not to run
that particular function if they choose. I have set the
warnings off and wanted to put my own message. Any ideas,
please? By the way, this function calls for a query to run.
.

.
.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top