Need help with code

L

Lasse T

A simple one for most of you.

Could someone please provide me with a code that creates a message box with
two buttons, yes and no.
The "no" button stops and return to the form and the "yes" button continues.

Thanks in advance.

Lasse T
---------------
 
J

JSand42737

"Lasse T" said:
A simple one for most of you.

Could someone please provide me with a code that creates a message box with
two buttons, yes and no.
The "no" button stops and return to the form and the "yes" button continues.

Thanks in advance.

Lasse T
---------------

Lasse

If you are running the code from a Command Button's OnClick event, then you can
use something like:

Private Sub Command2_Click()
If vbYes = MsgBox("Please press either Yes or No", vbYesNo, "??") Then
' Carry on with code
Else
' Don't process any more code
End If
End Sub
 
F

fredg

Lasse said:
A simple one for most of you.

Could someone please provide me with a code that creates a message box with
two buttons, yes and no.
The "no" button stops and return to the form and the "yes" button continues.

Thanks in advance.

Lasse T
Lasse,
Where are you doing this?
In a Control's BeforeUpdate event perhaps?

Dim intResponse as Integer
intResponse = MsgBox("Your message here",vbYesNo)
If intResponse = vbNo Then
Cancel = True
End If
End Sub
 
L

Lasse T

Thanks a lot. It works just fine.
Seems I need to start learning some VBA soon :)

Lasse T
--------------
 

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