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 
Runtime Error 2046
Dan Jackson 
            
4 years ago
Hi Guys!

I'm jumped back into developing my database to add a few new features. One of them worked initially but now it doesn't.

It's a delete record button.

YES! I KNOW! Deleting is BAD! As you'll see from the code, its password protected so only I or the boss can use it. He's had "The Talk" and will only be used for bogus entries lol!

Private Sub Button_DeleteRecord_Click()

Dim strInput As String
Dim strMsg As String

Beep
strMsg = "Input Password"
strInput = InputBox(Prompt:=strMsg, Title:="Delete Confirmation")
If strInput = "His Password" Or strInput = "My Password" Then 'password is correct

    If MsgBox("Are you SURE you want to delete this record?" & vbCrLf & _
    "This will permanently delete the record.", vbYesNo, "2nd Delete Confirmation") = vbYes Then
         DoCmd.RunCommand acCmdDeleteRecord
         MsgBox ("Client Deleted")
    End If

Else 'password is incorrect
MsgBox "Incorrect Password", vbCritical, "Invalid Password"
Exit Sub
End If

End Sub


- Bold is where the Debugger Stops
- Compiler shows no errors, completes fine
- Write access to the backend confirmed ok
- Pic 1 is the error generated in the encrypted FE
- Pic 2 is the error generated in the dev FE

Many thanks for the help
Dan Jackson OP  @Reply  
            
4 years ago

Dan Jackson OP  @Reply  
            
4 years ago

Kevin Robertson  @Reply  
          
4 years ago
Check the AllowDeletions property. It needs to be set to true.
Or you could use an SQL statement to delete the record then requery the form.
Adam Schwanz  @Reply  
           
4 years ago
Looking online "It doesn't work because you've disabled the toolbar, enable it or run a delete query insted"

Try the Currentdb.execute "DELETE * FROM TABLENAME WHERE ID=" & ID
Dan Jackson OP  @Reply  
            
4 years ago
Kevin - Allowdeletions is on, thanks

Adam - Worked great BUT i'm now stuck on the form unable to close. I tried adding Docmd.close over the confirmation but didn't work. Thank you
Adam Schwanz  @Reply  
           
4 years ago
So putting this in there doesn't actually close it? voodoo

docmd.Close acForm,"formname"
Dan Jackson OP  @Reply  
            
4 years ago
Beautiful! For some reason, specifying the name fixed the issue. Furthermore, i threw in a

Forms!MYSEARCHFORM.Requery

for good measure. All working, thanks buddy

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/7/2026 12:56:47 PM. PLT: 0s