I need to watch this message also.
I get an error on the Me.Requery at the end
With SetWarnings True, I also get the warning, and when I said yes or no, it
deleted again.
When I removed the SetWarnings True line, it deleted my record and the next
one.
I have the code in the OnDelete event, of the child/detail form, when the
user clicks the row header and presses delete. I have a separate delete on a
command button also, but that one is executed from the parent form.
My code is below:
Private Sub Form_Delete(Cancel As Integer)
Dim nParentProjectID
Dim nProjectID
Dim nItem
Dim Response
If isManagement() Then
DoCmd.SetWarnings False
If Not Me.NewRecord Then
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me.ProjectId.SetFocus
nParentProjectID = .[ParentProjectID]
nProjectID = .[ProjectId]
nItem = .[Item]
Response = MsgBox("This function will DELETE the CURRENT
ISSUE LINE, " & vbCrLf & _
"AND its associated CYCLE LINES!" &
vbCrLf & vbCrLf & _
"There is ***NO UNDO***!" & vbCrLf &
vbCrLf & _
"Parent Project ID: " &
nParentProjectID & vbCrLf & vbCrLf & _
"CONFIRM DELETE of Project #: " &
nProjectID & ", " & "and CURRENT Issue #: " & nItem & "?" _
, vbCritical + vbYesNo, "Are You Sure?")
If Response = vbYes Then
.Delete
End If
End With
Else
MsgBox "The Current Issue is a New line and cannot be deleted."
& vbCrLf & vbCrLf & _
"Please click on the 'row header button' to select the
row for deletion, " & vbCrLf & _
"and then press Delete again.", , "Cannot Delete a New
Line"
End If
Else
MsgBox "Only BA's and Managers can delete an Issue line" & vbCrLf &
vbCrLf & _
"Please give the Project # and Issue # to a BA or Manager,
for deletion", vbExclamation, "User Not Authorized To Delete"
End If
Me.Requery
DoCmd.SetWarnings True
End Sub