Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    acCmdDeleteRecord not working (2003)

    For some reason the acCmdDeleterecord code in the following has stopped working...
    I have a form which contains reminder notes. If the reminder note date is less than today then I have the option of deleting the note.
    The following code (which runs on load) runs fine, asks me the proper question, but when I answer 'yes', it bypasses the 'DoCmd.RunCommand acCmdDeleteRecord' code.
    I even put in another msgbox command just before it to ensure that it registered the 'yes' and the message box showed fine, but it still wont run this command.
    I have the DoCmd.RunCommand acCmdDeleteRecord coded in another button on the form and it works fine.

    Can anyone help with this problem? Thanks in advance!

    If Me!txtTicklerDate <= Date Then
    ' Delete any expired reminders
    If msgbox("The date for this reminder has expired. " _
    & "Click Yes to delete the reminder, No to edit it." _
    , vbYesNo + vbQuestion, "Expired Reminder") = vbYes Then
    DoCmd.RunCommand acCmdDeleteRecord
    Else
    Me!txtTicklerDate.SetFocus
    End If
    End If

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: acCmdDeleteRecord not working (2003)

    You may have to change

    DoCmd.RunCommand acCmdDeleteRecord
    to
    RunCommand acCmdDeleteRecord

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord not working (2003)

    Had a go Pat, unfortunately it didn't make any change. The code still skips it.

    Thanks anyway.

  4. #4
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Royal Oak, Michigan, USA
    Posts
    255
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord not working (2003)

    I recreated everything from your initial post...the table, the form, the field and pasted the code from your post into the OnLoad event. Everything worked fine...the question was asked and the record was deleted. I know this might sound stupid but try deleting the code from the OnLoad event, save the form and then paste the code back into the OnLoad event and see if that works. Everythin else looks fine.

  5. #5
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord not working (2003)

    Ummm. I delete the code, click on save. Close the VB window, save the form.
    Then I test the form, it doesn't ask the question.
    I close the database, open the database... and the code is back....
    Something screwy is going on here....
    I repeated the above, but instead of closing the database, I did a compact and repair... and the code came back....
    can anyone tell me what is going on here? My edits and changes don't stick!

  6. #6
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord not working (2003)

    OK, I'm tracking this down.
    When I answer 'yes' to the question, then try to delete the record manually I get the message:
    "Could not update; Currently locked by another session on this machine"
    yet when I answer 'no', I can delete the record manually with no problem.
    So what could be locking this record, and, more importantly, how do I unlock it?
    Thanks again.

  7. #7
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord not working (2003)

    So can anyone tell me what might be causing this

    "Could not update; Currently locked by another session on this machine"

    message and how I can resolve this issue?

    Thanks in advance again!

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord not working (2003)

    <hr>Ummm. I delete the code, click on save. Close the VB window, save the form.
    Then I test the form, it doesn't ask the question.
    I close the database, open the database... and the code is back....
    <hr>
    Seems to me the database is corrupted. As Compact and Repair don't work, try JetComp, available here.
    If this fails, create a new empty database and try to import all the objects from the corrupted one.
    Francois

  9. #9
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: acCmdDeleteRecord not working (2003)

    Why not put this code in another form (form A), this form would not be bound to the same table (I presume that this is the problem?). All it would do is what you are trying to do in the other form (form [img]/forums/images/smilies/cool.gif[/img].
    At the completion of the code in form A, either deleting or not, you would call the form (form [img]/forums/images/smilies/cool.gif[/img] in question.

Posting Permissions

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