Home
Home

---Soumis par Dev Ashish---

Effacer l'enregistrement actuel.

    Si vous n'aimez pas utiliser l'interface utilisateur  DoMenuItem générée par le Wizard (Assistant) de boutons pour un  Delete Record, vous pouvez utiliser, en lieu et place de:

 

Private Sub DeleteCurrentRecord_Click()
    If Not (fDelCurrentRec(Me)) Then
        MsgBox "Une erreur inattendue s'est produite!"
    End If
End Sub

 

  la fonction:  (Merci à Andy Baron pour sa suggestion à propos de .NewRecord!)

'************** Code Start *************
Function fDelCurrentRec(ByRef frmSomeForm As Form) As Boolean
    On Error GoTo Err_Section
    
    With frmSomeForm
        If .NewRecord Then
            .Undo
            fDelCurrentRec = True
            GoTo Exit_Section
        End If
    End With
    
    With frmSomeForm.RecordsetClone
        .Bookmark = frmSomeForm.Bookmark
        .Delete
        frmSomeForm.Requery
    End With
    fDelCurrentRec = True
Exit_Section:
    Exit Function

Err_Section:
    fDelCurrentRec = False
    Resume Exit_Section
End Function
'************** Code End *************