delete record button

F

Fipp

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

Allen Browne

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
 
R

RogerSoft

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

RogerSoft

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?
 
D

Douglas J. Steele

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
 
R

RogerSoft

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?
 
D

Douglas J. Steele

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