Hi Everyone,
I am trying to do the following but can't seam to get it right, part of it works but not all, any guidance would be greatly received.
On the Subform which is in Datasheet view
in the OnDelete event, I have the following code
Private Sub Form_Delete(Cancel As Integer)
If DLookup("[CostsID]", "QryFinanceRecordNotes") > 0 Then
MsgBox ("There have been Notes added to this record, please delete the notes first before Deleting the Record"), vbInformation, "Hi Just to let you know"
Exit Sub
End If
End Sub
This is fine, but it still triggers the prompt to delete the record, so I added
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
Cancel = True
DoCmd.CancelEvent
End Sub
This stops the record from being deleted.
My problems is as follows
If I want to check that there are no Notes added to this record
I want to be able to delete the record
Could someone guide me on how to modify the code to check that there are no Notes so that I can Delete the record?
Thanks
CNEILL
I am trying to do the following but can't seam to get it right, part of it works but not all, any guidance would be greatly received.
On the Subform which is in Datasheet view
in the OnDelete event, I have the following code
Private Sub Form_Delete(Cancel As Integer)
If DLookup("[CostsID]", "QryFinanceRecordNotes") > 0 Then
MsgBox ("There have been Notes added to this record, please delete the notes first before Deleting the Record"), vbInformation, "Hi Just to let you know"
Exit Sub
End If
End Sub
This is fine, but it still triggers the prompt to delete the record, so I added
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
Cancel = True
DoCmd.CancelEvent
End Sub
This stops the record from being deleted.
My problems is as follows
If I want to check that there are no Notes added to this record
I want to be able to delete the record
Could someone guide me on how to modify the code to check that there are no Notes so that I can Delete the record?
Thanks
CNEILL