Question : Save Button - Undo Null Subform Record

I have a command button intended to save the record and subform records on a form.  

The subform has code in the before update event that test for null values and prevents the user from proceeding to another field until the errot test is passed.  The problem arises if the user begins to enter data, deletes the data, and then decides to save the form.  The save is not allowed because there are null values in the last record of the subform.  I need to undo the last record if there are null values and the users wishes to save.

Answer : Save Button - Undo Null Subform Record

You basically need these four pieces to implement deleting a record:

Button on form to Delete:
Private Sub cmdDelete_Click()
    DoCmd.RunCommand acDeleteRecord  ' This will trigger the Form_Delete event below.
End Sub

This code in the following three Form events:

Private Sub Form_Delete(Cancel As Integer)
    Beep
    'This message or something similar
    If MsgBox(""Are you SURE you want to DELETE this record?." & Chr(13) & "This operation cannot be undone", 292, "Delete Record") <> vbYes Then
        Cancel = True
    End If  
End Sub

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
  Response = acDataErrContinue
End Sub

Private Sub Form_AfterDelConfirm(Status As Integer)    
    Me.Requery
    DoEvents
End Sub
---------------
mx
Random Solutions  
 
programming4us programming4us