Command button question using "Yes" and "No"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I go about setting up a command button so that if I click "yes"
the code proceeds and if I click "no" the code is cancelled. The code I have
at the moment is this in the "click" event:


Me.CreInv.Value = True
Me.Qry_Status = "Outstanding"
Me.Cont_DateInv = Date

DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenForm "Queries Edit form", , , "QueryID = " & Me.QueryID & ""
DoCmd.Close acForm, "menu", acSaveNo




Cheers!
 
Try something like


If MsgBox ("Would you like to continue?", vbYesNo) = vbYes Then
Me.CreInv.Value = True
Me.Qry_Status = "Outstanding"
Me.Cont_DateInv = Date

DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenForm "Queries Edit form", , , "QueryID = " & Me.QueryID & ""
DoCmd.Close acForm, "menu", acSaveNo
End If
 
scubadiver said:
How would I go about setting up a command button so that if I click "yes"
the code proceeds and if I click "no" the code is cancelled. The code I
have
at the moment is this in the "click" event:


Me.CreInv.Value = True
Me.Qry_Status = "Outstanding"
Me.Cont_DateInv = Date

DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenForm "Queries Edit form", , , "QueryID = " & Me.QueryID & ""
DoCmd.Close acForm, "menu", acSaveNo




Cheers!

Where would you click Yes or No? If the code is in the command button click
event, there is no opportunity to stop it unless you do something like add a
message box before the SaveRecord line of code.
 
Back
Top