Delete Record Using Checkbox

Posted on 2011-05-12
Last Modified: 2012-06-21

I have a form in DataSheet View. I want to click on the checkbox to delete a record. When I first open the form and click on the checkbox, a message pops up saying "You are about to Delete 0 Record(s)". When I click off the checbox then the pop up says "You are about to Delete 1 Record(s)". When I click ok it shows #Deleted in the textboxes. I am not sure why I have to click off the checkbox to delete the record.

Private Sub DeleteRecord_Click()
DoCmd.RunSQL "Delete * From Data WHERE chkBox = True;"
End Sub

Open in new window

Question by:RecipeDan
    LVL 12

    Expert Comment

    Is the checkbox located in the same record as the record you want to delete or at the Mainform?

    LVL 30

    Expert Comment

    Try it in the Form_Afterupdate event
    LVL 30

    Accepted Solution


    Private Sub chkBox _Click()
        Me.Dirty = False
        DoCmd.RunSQL "Delete * From a WHERE chkBox = True;"
    End Sub

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now