Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2002
    Posts
    75

    Unanswered: Problem with Cancelling Form's Delete Event

    Hello All!

    I have some validation code in a form's (Continuous view) Form_Delete event:

    If UserID=ProjManagerID then
    if Cond1 or Cond2 then
    Cancel=true
    msgbox "Invoice No. " & me!InvoiceNo & " cannot be deleted!"
    end if
    else
    Cancel=true
    msgbox "You have no permission to delete Invoice No. " & me!InvoiceNo & "!"
    end if

    If based on conditions cancel remains false, the record gets deleted and everything works fine. But if cancel becomes true, the entire Form_Delete event is being executed again for the very same record.

    Could anyone shed light upon this weirdness and explain why it gets executed twice?

    Thanks a lot!

  2. #2
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    119
    The code looks ok - I mean it should work.
    The only way I can see this not working properly is if the UserID = ProjManagerID but cond1 and cond2 aren't true but they should be. But as for it executing twice that is weird.

    The code is definitley running on the OnDelete of the form?
    Regards
    JD

    Software-Matters

  3. #3
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    Put breakpoints against each line and then evaluate the logic and field values - this should shed some light on the issue;

    What are Cond1 or Cond2 - are they variables? If this is not the full code, post it please - Oh yeah - and is this thread a duplication?
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

Posting Permissions

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