Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Location
    Washington D.C.
    Posts
    164

    Unanswered: On Delete Event ...Before Delete Confirmation

    Hi,
    Before I delete a record on from a form, I want to check and see if that ID exists in another table, If so I want to discouninue the delete procedure, here is my code:
    (I'm using a SQL server backend)

    Dim CSet As ADODB.Recordset
    Dim strSQL

    strSQL = "Exec dbo.SP_FindCompanyOnDelete " & Me!CompanyID

    Set CSet = New ADODB.Recordset
    CSet.ActiveConnection = CurrentProject.Connection
    CSet.Open strSQL
    If CSet.EOF Then
    CSet.Close
    Exit Sub
    Else
    CSet.Close
    MsgBox "There are Contacts assigned to this company." _
    & Chr(13) & "Delete the company from those contacts first and then delete the Company.", vbCritical, "Delete Responses First"
    End If


    My problem is that I don't know how to stop the MS Access delete procedure ?

  2. #2
    Join Date
    Jan 2003
    Location
    Aberdeen, Scotland, UK
    Posts
    168
    on the Form_AfterDelConfirm or the Form_BeforeDelConfirm just:

    cancel = true
    docmd.cancelevent

  3. #3
    Join Date
    Dec 2002
    Location
    Washington D.C.
    Posts
    164
    Thanks.
    its working


    Originally posted by johncameron
    on the Form_AfterDelConfirm or the Form_BeforeDelConfirm just:

    cancel = true
    docmd.cancelevent

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •