Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...it was ingeniously designed and all those clicks were for my own good... and that was even before I got my speedy and useful answer to my tekkie question that I eventually posted..."

Geography

Where in the world do Tek-Tips members come from?

Problems with deleting a record Error 2501Helpful Member! 

Triacona (TechnicalUser)
28 Jun 12 6:43
Dear All,
Thanks for a great forum, like the upgrade! smile

I have a problem deleting a records.

I have made my own message box to inform the user that they are deleting the record.

The problem is if they click Yes, another message box appears and says:

Quote (Message Box)

Relationships that specify cascading deletes are about ot cause 1 record(s) in this table and in related tables to be deleted.
Are you sure you want to delete these records? - Yes No Help

If the user chooses Yes, then it is fine and the record is deleted, with all linked records, great, exaclty what I want, except for the extra message box...

I could live with that, BUT, if the user then decides, oh no I don't want to delete the record, and clicks No.

The following error occurs:

Quote (Run-time error '2501')

The RunCommand action was canceled

This will serve to confuse users.

Is there a way to get rid of the secondary message box(below)?:

Quote (Message Box)

Relationships that specify cascading deletes are about ot cause 1 record(s) in this table and in related tables to be deleted.
Are you sure you want to delete these records? - Yes No Help

So I just have my MsgBox?

My code is below:

CODE --> button

Private Sub QuestDeleteEntire_Click()
On Error GoTo Err_QuestDeleteEntire_Click



If msgbox("Are you sure you want to delete this record?", vbYesNo, "DELETE RECORD!!") = vbYes Then

    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdDeleteRecord
    
End If

Exit_QuestDeleteEntire_Click:

    'Me.[Forms.QuestionnaireFormClose].Requery


Exit Sub
Err_QuestDeleteEntire_Click:

    If Err.Number = 2501 Then        
        msgbox "Record not deleted"
     Else
        msgbox Err.Description
     End If
    
    Resume Exit_QuestDeleteEntire_Click
    
End Sub 
Your help is greatly appreciated! bigsmile
Thanks you!

Thank you,

Kind regards

Triacona

Triacona (TechnicalUser)
28 Jun 12 6:47
Private Sub QuestDeleteEntire_Click()
On Error GoTo Err_QuestDeleteEntire_Click

If msgbox("Are you sure you want to delete this record?", vbYesNo, "DELETE RECORD!!") = vbYes Then

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

End If


Exit_QuestDeleteEntire_Click:

'Me.[Forms.QuestionnaireFormClose].Requery


Exit Sub

Err_QuestDeleteEntire_Click:

If Err.Number = 2501 Then
msgbox "Record not deleted"
Else
msgbox Err.Description
End If

Resume Exit_QuestDeleteEntire_Click

End Sub

Thank you,

Kind regards

Triacona

Helpful Member!  PHV (MIS)
28 Jun 12 15:14
What about this ?
...
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
...

Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

Triacona (TechnicalUser)
29 Jun 12 4:50
Dear PHV,

AWESOME thanks so so much! 2thumbsupbigsmile
It works!
Have a star! smile
It was quite a frustrating problem, thanks again!

Thank you,

Kind regards

Triacona

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close