Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2011
    Posts
    103

    Unanswered: Delete button on SubForm

    So, I'm trying to delete a record from a sub form. I'm using a delete query since I couldn't get the record delete button wouldn't work when I create the button using button command wizard.

    Here's my code for Delete query.

    Code:
    DELETE Taxable_Facility.PropertyID, Taxable_Facility.TaxDue, Taxable_Facility.DueDate, Taxable_Facility.PaidDate
    FROM Taxable_Facility
    WHERE (((Taxable_Facility.PropertyID)=[Forms]![TaxableQuery]![PropertyID]) AND ((Taxable_Facility.TaxDue)=[Forms]![TaxableQuery]![TaxDue]) AND ((Taxable_Facility.DueDate)=[Forms]![TaxableQuery]![DueDate]) AND ((Taxable_Facility.PaidDate)=[Forms]![TaxableQuery]![PaidDate]));
    Here's the code for the button.

    Code:
    Private Sub Command54_Click()
    On Error GoTo Err_Command54_Click
        
        Beep
        If MsgBox("Are you sure you want to delete the current record?", vbQuestion + vbYesNo, "Delete Current Record?") = vbYes Then
            stDocName = "DeleteTaxSubFrmRec"
        DoCmd.OpenQuery stDocName, acNormal, acEdit
        Me!TaxableQuery.Requery
        End If
        
    Exit_Command54_Click:
        Exit Sub
        
    Err_Command54_Click:
        If Err = 2046 Then 
            MsgBox "There is no record to delete.", vbCritical, "Invalid Delete Request"
            Exit Sub
        ElseIf Err = 2501 Then 
            Exit Sub
        Else
            MsgBox Err.Number & " - " & Err.Description
            Resume Exit_Command54_Click
        End If   
    End Sub
    What am I missing? When click the button it keeps asking for the parameters.

  2. #2
    Join Date
    Jan 2012
    Posts
    97
    Try referencing your sub form through your main form in the query and see if that makes any difference:

    Forms![mainform]![subform]![control]
    Hope this helps,

    Dave.

    _____________

    Access 2000 User

  3. #3
    Join Date
    Nov 2011
    Posts
    103
    That did the trick. It's working now. Much appreciate!

  4. #4
    Join Date
    Jan 2012
    Posts
    97
    Your welcome.
    Hope this helps,

    Dave.

    _____________

    Access 2000 User

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •