Query

D

dizzy

how do I write a code (or any other way) that will ask if
you are sure you want to modify a record. it should give
the following options, Yes, No, Cancel.
thanks in advance
 
G

Gerald Stanley

Try something along the lines of

If MsgBox("Do You Wish to Modify This Data?",
vbYesNoCancel) = vbYes Then
<write update logic)
End If

Hope That Helps

Gerald Stanley MCSD
 
J

John Vinson

how do I write a code (or any other way) that will ask if
you are sure you want to modify a record. it should give
the following options, Yes, No, Cancel.
thanks in advance

Use the Form's BeforeUpdate event which is cancellable. What do you
want to happen if the user answers No, vs. Cancel? Sounds a bit
confusing to me! Assuming that by Yes you mean "save the modified
record", by No you mean "restore everything on the form to where it
was before I edited", and Cancel "don't do anything but go back to the
record" then try code like this:

Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns as Integer ' define a variable to hold the answer
iAns = MsgBox("Do you want to save your changes?", vbYesNoCancel)
' open the VBA editor and see the online help for MsgBox for more
' options
Select Case iAns
Case vbYes
' do nothing
Case vbNo
' Undo all the changes to the form
Me.Undo
Cancel = True
Case vbCancel
' Cancel the update but continue
Cancel = True
End Select
End Sub
 
D

dizzy

thank you
-----Original Message-----


Use the Form's BeforeUpdate event which is cancellable. What do you
want to happen if the user answers No, vs. Cancel? Sounds a bit
confusing to me! Assuming that by Yes you mean "save the modified
record", by No you mean "restore everything on the form to where it
was before I edited", and Cancel "don't do anything but go back to the
record" then try code like this:

Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns as Integer ' define a variable to hold the answer
iAns = MsgBox("Do you want to save your changes?", vbYesNoCancel)
' open the VBA editor and see the online help for MsgBox for more
' options
Select Case iAns
Case vbYes
' do nothing
Case vbNo
' Undo all the changes to the form
Me.Undo
Cancel = True
Case vbCancel
' Cancel the update but continue
Cancel = True
End Select
End Sub



.
 
D

do you do any consulting?

-----Original Message-----


Use the Form's BeforeUpdate event which is cancellable. What do you
want to happen if the user answers No, vs. Cancel? Sounds a bit
confusing to me! Assuming that by Yes you mean "save the modified
record", by No you mean "restore everything on the form to where it
was before I edited", and Cancel "don't do anything but go back to the
record" then try code like this:

Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns as Integer ' define a variable to hold the answer
iAns = MsgBox("Do you want to save your changes?", vbYesNoCancel)
' open the VBA editor and see the online help for MsgBox for more
' options
Select Case iAns
Case vbYes
' do nothing
Case vbNo
' Undo all the changes to the form
Me.Undo
Cancel = True
Case vbCancel
' Cancel the update but continue
Cancel = True
End Select
End Sub



.
 
J

John Vinson

On Tue, 27 Jan 2004 15:25:41 -0800, "do you do any consulting?"

Who's asking? and who are you asking?
 

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