Results 1 to 13 of 13
  1. #1
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016

    Error 2046: The command or action 'DeleteRecord' isn't available now.

    Perhaps this is a recognized problem, but I troll here and four other forums about 6-8 hours a day, and have for the past ten years, and have never seen it mentioned before.

    Running v2007, while working on a problem for someone else, I found that, on any given Form, using the code

    Code:
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdDeleteRecord


    works as expected, if the Form is in Single View or Continuous View, but always fails if the Form is in Datasheet View!

    Just to be clear, this is happening on a single Form, with it simply being running in three different views. And in verifying the problem, I ran the same procedure on three different Forms, in one Database, then did the same thing in three different Forms, in another Database...all with the same result!

    All Forms were as basic as basic can be, with all being based on a single (albeit different) Table.

    Any ideas?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    FWIW, I put a button named cmdDelete on form frmMain. The button's onclick event procedure is the 2 lines of code.
    Then from the immediate window
    Code:
    Call Form_frmMain.cmdDelete_click
    worked OK when form was in datasheet view.
    It WILL produce the error if the datasheet row selected is the 'add record' row and the row is empty.
    Last edited by davegri; 05-17-2017 at 03:56 PM. Reason: more

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Gave me same error as before...and calling code from the Immediate Window isn't really a workaround, is it? I tested the code, in Datasheet View, by using the Double-Click event of a Textbox.

    Also note that since my original post:

    I checked to make sure all service packs were installed, and they were.

    The Record can be deleted, in Datasheet View, using 'Delete Record' from the Ribbon.

    I finally found, as a workaround, you can use code, by replacing

    DoCmd.RunCommand acCmdDeleteRecord
    with

    DoCmd.RunCommand acCmdCut

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Gave me same error as before...and calling code from the Immediate Window isn't really a workaround, is it?
    Just trying to provide a helpful clue, my man. Just a clue.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Did you read far enough down in that thread where someone posted that setting the AllowDesignChanges to False allowed the record to be deleted (#15)? In 2007 I tried it on a form in data sheet view and using a double click event on the record, was able to delete it. I confirmed the deletion by checking the table. Oddly enough though, I wasn't allowed to set the property in a form open event so I used the immediate window. I've never used that property and am not sure I see the point of it since you can still open it manually in design view and alter the design and save it successfully. If it was meant to prevent coded design changes, then how easy would it be to override that??
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Quote Originally Posted by davegri View Post
    Just trying to provide a helpful clue, my man. Just a clue.
    I understand...and all additional info/clues help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Quote Originally Posted by Micron View Post
    Did you read far enough down in that thread where someone posted that setting the AllowDesignChanges to False allowed the record to be deleted (#15)?
    Actually...no! I got distracted in reading it and something made me wonder about the status of the SPs. But, in point of fact, while I remember this Property from previous versions, in my install of 2007, I can't find the Property! I've been thru the 'all' tab five times, tried finding it using 'help,' and nada!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  9. #9
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Did you read far enough down in the thread?? It says that this property can only be set in VBA.

  10. #10
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Tried that, too, no luck. Forget what error it popped.

    As I said, this was not really a pressing need...just curious!

    And, as above, found an easy workaround!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by Missinglinq View Post
    Tried that, too, no luck. Forget what error it popped.
    Linq ;0)>
    that's why I did it in the immediate window.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Even for the Boys of Redmond this is a strange bug, isn't it?
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  13. #13
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Don't know. They're a a strange bunch so maybe it's normal for them.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 11-30-2015, 01:06 PM
  2. Replies: 3
    Last Post: 01-02-2015, 02:06 PM
  3. Replies: 4
    Last Post: 12-12-2014, 08:48 AM
  4. Run-time error 2046
    By Evans2 in forum Forms
    Replies: 8
    Last Post: 09-06-2014, 01:52 PM
  5. Replies: 3
    Last Post: 06-09-2012, 08:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums