Query

  • Thread starter Thread starter dizzy
  • Start date Start date
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
 
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
 
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
 
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



.
 
-----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



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

Who's asking? and who are you asking?
 
Back
Top