run code prior to command execute

  • Thread starter Thread starter Lapchien
  • Start date Start date
L

Lapchien

I'd like to add a messagebox warning with a yes/no after a user has clicked
a command button, something like 'Do you really want to process this?" If
they say No, the it will not run and put them back to the 'Menu' form, if
they say Yes it will execute the command as normal...

Thanks,
Lap
 
Enter the following code in the Clicked event of the button:


Dim Reply As VbMsgBoxResult
Reply = MsgBox("Are you sure? ", vbYesNo + vbExclamation +
vbDefaultButton2, "Title ....")
If Reply = vbYes Then

enter your code here

End If

--
Jonathan Blitz
AnyKey Limited
Israel

"When things seem bad
Don't worry and shout
Just count up the times
Things have worked themselves out."
 
Try something along the following lines

Private Sub Comand_Click()
If Msgbox("Do You Really Want To Process This?", vbYesNo) =
vbNo Then
Exit Sub
End If

<rest of the logic>
End Sub

Hope That Helps
Gerald Stanley MCSD
 
Lap,

Something like this...

Private Sub YourButton_Click()
Dim MsgAnswer As Integer
MsgAnswer = MsgBox("Oh really?", vbYesNo, "box title")
If MsgAnswer = vbYes
<your procedure code here>
End If
End Sub
 
Many thanks guys!


Steve Schapel said:
Lap,

Something like this...

Private Sub YourButton_Click()
Dim MsgAnswer As Integer
MsgAnswer = MsgBox("Oh really?", vbYesNo, "box title")
If MsgAnswer = vbYes
<your procedure code here>
End If
End Sub
 
Back
Top