Command button question using "Yes" and "No"

S

scubadiver

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!
 
O

Ofer Cohen

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
 
B

BruceM

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.
 

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