confirmation and close

  • Thread starter Thread starter bigandyt
  • Start date Start date
B

bigandyt

i was wondering if it is possible to insert vb code in a macro that wil
display to the user "are u sure u want to do this" or along thos
lines, if yes the rest of the macro is executed else the macro stops.


also i want to get rid of the 'X' at the top right of my form so th
user cannot close the form is this possible

any help would be appreciated

And
 
Andy,

try this:

Sub Sure()

If MsgBox("Are you sure you want to cuntinue ?", vbYesNo, "Countinue ?") =
vbNo Then Exit Sub

'Go on with the code which has to be executed here
MsgBox ("You decided to continue")

End Sub
 
Hi Andy
If MsgBox("Are you sure you want to do this?", vbYesNo + vbsuestion, "Please
confirm") = vbNo Then Exit Sub
MsgBox "not cancelled"
'do your stuff

To prevent closing your form add this into the form's code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode <> 1 Then Cancel = 1
End Sub

HTH
Cordially
Pascal
 
Sorry please amend :
If MsgBox("Are you sure you want to do this?", vbYesNo + vbQuestion, "Please
confirm") = vbNo Then Exit Sub

Pascal

papou said:
Hi Andy
If MsgBox("Are you sure you want to do this?", vbYesNo + vbsuestion, "Please
confirm") = vbNo Then Exit Sub
MsgBox "not cancelled"
'do your stuff

To prevent closing your form add this into the form's code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode <> 1 Then Cancel = 1
End Sub

HTH
Cordially
Pascal
 

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

Back
Top