delete record button

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

Guest

I have a button and I am trying to get it to delete the current record on a
form.
the button is named "deleteformation"
I would also like to have a confirmation message box pop up asking me if I
am sure I would like to delete the record. if No action is canceled?

Any help on that code?

Thanks for your help. You guys are great!
 
There is a wizard to create a delete button for you.
Access automatically gives you the confirmation message (unless you turned
it off.)

The wizard code isn't very good. You might want to use this:

Private Sub deleteformation_Click()
If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If
End Sub
 
Hi All,

I have a similiar, yet different, problem.

In my form I have a "Cancel record creation" button that has the "Undo"
command behind it, so that the record doesn't get created and the record
number doesn't increase by one unit.

Although this works just fine, I would like a confirmation message box so
that something doesn't get undone accidentally.

Any ideas on how this can be done?

Thanks in advance.
Regards,
Rogerio.
 
Allen Browne said:
So, add a MsgBox() around the Undo line.
Correct me if I'm wrong, but isn't the message box only informative? Can I
get the message box to ask me yes/no and continue or cancel depending on the
answer?

How can I do that?
 
RogerSoft said:
Correct me if I'm wrong, but isn't the message box only informative? Can I
get the message box to ask me yes/no and continue or cancel depending on
the
answer?

You're wrong. <g>

There are two flavours of msgbox. One's a function that returns the details
of the button that was clicked.

If MsgBox("Select Yes Or No", vbYesNo) = vbYes Then
MsgBox "You selected Yes"
Else
MsgBox "You selected No"
End If
 
You're wrong. said:
There are two flavours of msgbox. One's a function that returns the details
of the button that was clicked.

If MsgBox("Select Yes Or No", vbYesNo) = vbYes Then
MsgBox "You selected Yes"
Else
MsgBox "You selected No"
End If
I see, so I just need to add the action that I want instead of the MsgBox
"You selected Yes" that you wrote on the code abova, right?
 
RogerSoft said:
I see, so I just need to add the action that I want instead of the MsgBox
"You selected Yes" that you wrote on the code abova, right?

Yes.
 

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

Back
Top