This is the Click event code for a delete button on a form.
I'm trying to check if the record that is being deleted is active in another table. There should be only one active instance of the record so dcount isn't required, but I don't know any better.
When I run this code in a stand alone form it works fine.
When the form is running as a subform I get the alarm
"You canceled the previous operation"
and it jumps to the error handler.
Any one experienced this before?
Much thanks in advance,Rich
Access 02 Win xp/98
I'm trying to check if the record that is being deleted is active in another table. There should be only one active instance of the record so dcount isn't required, but I don't know any better.
When I run this code in a stand alone form it works fine.
When the form is running as a subform I get the alarm
"You canceled the previous operation"
and it jumps to the error handler.
Any one experienced this before?
Much thanks in advance,Rich
Access 02 Win xp/98
Code:
Private Sub Delete_Coopy_Record_Click()
On Error GoTo Err_Delete_Coopy_Record_Click
Dim strMessage1 As String
Dim strMessage2 As String
Dim intStyle As Integer
Const strTitle As String = "Delete Record?"
Dim bytResponse As Byte
Dim Count As Integer
Count = DCount("CopyKey", "qry_DeleteCopy_CopyEntry", "CopyKey = FK_CopyKey")
If Count > 0 Then
intStyle = vbCritical + vbOK + vbDefaultButton1
strMessage1 = "This copy is checked out and must be checked in before it can be deleted."
bytResponse = MsgBox(strMessage1, intStyle, strTitle)
Else:
intStyle = vbQuestion + vbYesNo + vbDefaultButton2
strMessage1 = "Are you sure you want to delete the Copy, "
bytResponse = MsgBox(strMessage1 & Me.CopyID & " " & Me.FK_ISBN, intStyle, strTitle)
End If
If bytResponse = vbYes Then
With DoCmd
.SetWarnings False
.RunCommand acCmdDeleteRecord
.SetWarnings True
End With
End If
Exit_Delete_Coopy_Record_Click:
Exit Sub
Err_Delete_Coopy_Record_Click:
MsgBox Err.Description
Resume Exit_Delete_Coopy_Record_Click
End Sub
Last edited: