Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
acCmdDeleteRecord
Gordon Merkosky 
     
2 years ago
I had an issue with this command. I had a Form open in the back ground that uses the on timer event. I would get the message "acCmdDeleteRecord is not available now". I got around it by setting the Time interval to 0 at the start of the code then setting it back at the end of the code. I am posting this because i spent many hours trying to figure it out. Here is the work around code i used.

DetailsPrivate Sub DelBtn_Click()

    Forms!PatListF.TimerInterval = 0
    
    If MsgBox("Do you wish to Remove the Current" & vbNewLine & "Record from this form?", _
            vbYesNo, "Remove Confirmation") = vbYes Then
        Me.Requery
        Me.AllowDeletions = True
        Me.AllowEdits = True
        DoCmd.SetWarnings False
        DoCmd.RunCommand acCmdDeleteRecord
        DoCmd.SetWarnings True
        Me.AllowDeletions = False
    End If
    
    Forms!PatListF.TimerInterval = 750
    
End Sub


hope this helps others having the same problem.
Kevin Robertson  @Reply  
           
2 years ago
Here's how I handle deletions.

If MsgBox("Are you sure you want to DELETE this contact?" & vbNewLine & vbNewLine & _
    "This action CANNOT be undone.", vbYesNoCancel, "Confirm Delete") <> vbYes Then Exit Sub

CurrentDB.Execute "DELETE FROM ContactT WHERE ContactID=" & ContactID


I only add a delete button for non critical data. Always be extremely careful when deleting records and make sure you have good backups.

Don't Delete Data
Backup Access
Access Backup Template
Kevin Yip  @Reply  
     
2 years ago
CurrentDB.Execute doesn't tell you if the record was actually deleted, nor does it give you any error message.  So I often invoke the RecordsAffected property afterwards:

     Dim db As Database, n As Long
     Set db = CurrentDB
     db.Execute "DELETE ... "
     n = db.RecordsAffected

In the above, n will be the number of records deleted.  For this code to work, we must save the "instance" of CurrentDB in the manner shown above.
Gordon Merkosky OP  @Reply  
     
2 years ago
I get what your saying. In my case i was only deleting the record from the form and not from the database.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 8:21:22 AM. PLT: 1s