Results 1 to 13 of 13
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    acCmdDeleteRecord (Access 97)

    I was using the statement DoCmd.Runcommand acCmdDeleteRecord to delete the current record but it refused to delete it! No error was raised as I would expect if there was a problem with permissions, non-updatable recordset etc. I got round it by writing a delete query, but I'm a bit perturbed by this command not working and not kicking out an error.

    Has anyone encountered anything similar?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: acCmdDeleteRecord (Access 97)

    You're going to have to provide more details about what was going on when it failed. For example, is that being executed from code within the form? If so, it it behind a button or somewhere else? Do you have any code running in the Delete event of the form that might interfere? Is the form's allowdeletions property set to True? Have you tried putting a breakpoint into your code to determine exactly what happens when you hit that line?
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord (Access 97)

    Hi - sorry for the lack of info on the original post.

    It is simply a button on the form, and it is intended to delete the current record in the forms's recordsource. There is no code triggered when deleting. Allow deletions is set to true. I have put a breakpoint on the line and it appears to execute the line and no error is generated, but the record remains in the table. If I run a delete query with criteria set to select the same record it works.

    I'm stuck! Let me know if there is any other information I could supply.

  4. #4
    Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord (Access 97)

    I have some more information which may or may not be related - I have another problem where the DoCmd.TransferSpreadsheet command does not work (I have checked that the table I am exporting has data and I have permission to write to the folder) - I have a feeling it has something to do with the 'DoCmd' object - is there some way of stopping DoCmd from working?

    Thanks

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: acCmdDeleteRecord (Access 97)

    Is the form's recordsource a query or a table? I a wondering if it is bound to a non-updatable query perhaps?
    If youy open the query will it let you delete rows from there?
    Regards
    John



  6. #6
    Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord (Access 97)

    The form's recordsource is indeed an updateable query, and I can delete from it when I open it. If it wasn't, would give me an error.

    Thanks

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: acCmdDeleteRecord (Access 97)

    Is the record in a subform? That will cause problems because the delete instruction applies to the current record on the *current* form. Have you changed SetWarnings to false before running the DoCmd? If so, remove or comment out the SetWarnings lines and you may discover what your problem is.
    Charlotte

  8. #8
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: acCmdDeleteRecord (Access 97)

    To test this theory try a few simple docmd actions like
    DoCmd.beep
    DoCmd.OpenForm "Employees", acNormal
    DoCmd.GoToRecord , , acNext
    Regards
    John



  9. #9
    Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord (Access 97)

    It's not in a subform - I took the warnings off, message poppeed up saying I am about to delete 1 record, command executes, but the record remains! And no error! I haven't got 'On error resume next' either.

    I do have a filter on the form, and what is interesting is that the record disappears from the filtered selection as you would expect, but if I re-apply the filter it re-appears. It never gets deleted from the table.

  10. #10
    Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord (Access 97)

    Other DoCmd commands seem to work fine. I created a new form over the query and added a delete record buttton with the DoCmd.RunCommand acCmdDeleteRecord, with no filters. Again it behaves as if it is deleting the record but when I close and re-open the form the record is still there.

    I wonder if it is possible to have relationships set up that prevent you from deleting a record? But that doesn't explain why I can delete it in query view....

    Actually, although I delete it and it vanishes in query view, it is still there when I close and re-open the query. How strange.

    Thanks

  11. #11
    Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord (Access 97)

    OK, problem solved! It turns out someone had been meddling with the database and had added a table to the query causing it to be non deleteable. I removed the joined table and that fixes the problem. It comes up with a warning that I am about to delete 1 record plus others elsewhere due to cascading deletes, which is correct. However, I don't understand why no error was kicked out when it failed defore, and why the record disappeared from the query, but then re-appeared when the query was re-opened.

    Before I discovered the extra table, it would warn me that I was deleting 1 record, but mentioned nothing about cascading deletes, so I think that might have something to do with it.

    Thanks for all your help.

  12. #12
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: acCmdDeleteRecord (Access 97)

    Could it be the case that deleting the record breaks referential integrity? Do you have relationships? Do you enforce referential integrity?
    *******
    added immediately ; Sorry I just noticed that you solved this problem
    Regards
    John



  13. #13
    Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: acCmdDeleteRecord (Access 97)

    Why didn't it give me an error though? I think it's very unusual behaviour for a record to disappear from a recordset without it actually being deleted.

Posting Permissions

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