Delete record crashes access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frys
    New Member
    • Dec 2007
    • 29

    Delete record crashes access

    Every time i attempt to delete a record access crashes

    i have a main form
    [Progdate]

    a sub form
    [Meeting ID]

    and a sub sub form
    [Attendance]

    so long as i do not expand the sub sub form i can delete the record form th esub form

    but if i expand the sub sub form it crashes

    is there a way to avoid this
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    If you have the Master/Child links setup between the form and between the nested subforms, the following code behind the form from which you select the record to be deleted should work:
    Code:
        DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdDeleteRecord
    If it does not work, post the master/child links between the nested subforms and the main form.

    Comment

    • frys
      New Member
      • Dec 2007
      • 29

      #3
      im sorry for sounding new.

      But do i put this code on the "On Delete" event or .. well i just don't know

      i really appreciate the help

      Comment

      • puppydogbuddy
        Recognized Expert Top Contributor
        • May 2007
        • 1923

        #4
        No, place the code behind a button on your form, as shown below:
        Code:
        Private Sub btnDelete_Click()
        On Error GoTo Err_btnDelete_Click
        
        Dim Cancel As Integer
        Dim intReturn As Integer
        
        On Error GoTo Err_btnDelete_Click
        
        intReturn = MsgBox("Warning: You are about to delete this record. If you don't want to do this, Click the cancel button.", vbOKCancel)
        
        If intReturn = vbCancel Then
                GoTo Exit_btnDelete_Click
        Else
                 DoCmd.RunCommand acCmdSelectRecord 
                 DoCmd.RunCommand acCmdDeleteRecord
                 Me.Refresh
        End If
        
        Exit_btnDelete_Click:
            Exit Sub
        
        Err_btnDelete_Click:
            MsgBox "Error# " & Err.Number & " " & Err.Description
            Resume Exit_btnDelete_Click
        
        End Sub

        Comment

        • frys
          New Member
          • Dec 2007
          • 29

          #5
          ah i see

          thanks ill give that a shot

          Comment

          Working...