Results 1 to 6 of 6
  1. #1
    skahle89 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2010
    Posts
    5

    The command "SelectRecord" isn't available now HELP!

    Hello all,

    I'm having a really irritating problem and I haven't been able to find a solution anywhere on the web. I'm using Access 2003 and I have a form thats controls are bound to a simple table.

    I created a "duplicate record" button using the wizard, and then tweaked the code just a little bit in my attempts to fix the problem:

    Private Sub btn_Duplicate_Click()
    On Error GoTo Err_btn_Duplicate_Click

    If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord

    'Duplicate the record
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

    'Focus on the Scenario ID, needs to be changed to unique value
    Forms![frm_LOPA_Master].[Scenario_ID].SetFocus

    Exit_btn_Duplicate_Click:
    Exit Sub

    Err_btn_Duplicate_Click:
    MsgBox Err.Description
    Resume Exit_btn_Duplicate_Click

    End Sub


    The code used to work correclty, but at some point I made some changes to the form properties, other control properties, or something else messed things up. When I click the "Duplicate Record" button, Access creates a new record, but none of original records values are carried over. No errors are trapped.

    If I put a break in the code and then step through, an error is trapped at the line: "DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70". The error message is:

    The command "SelectRecord" isn't available now

    I've tried using the following code as well, but I have the same problem:

    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdCopy
    DoCmd.RunCommand acCmdPasteAppend

    Does anyone know what causes a command to be unavailable? I've had this same problem while trying to "undo" because there was nothing to undo, but that was easily remedied by putting a "If Me.Dirty" condition in. What about selecting a record though; what could prevent a record from being selected?

    Regards,
    Seth

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It sounds like the recordset is no longer valid. Do you have a PrimaryKey on this table?

  3. #3
    skahle89 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2010
    Posts
    5
    Thanks for the reply RuralGuy

    Yes, the tables primary key is a field called Scenario_ID, which is of the "text" datatype. Obviously it is not auto-numbered, but each scenario is a unique identifier.

    It seems odd to me that I can easy save, delete, undo records, and create new... but not select and copy them (especially because I used to be able to). Would I just be better off writing vba procedure to store all the current form values, create a new record, then programmatically enter them in the new form? A little bit more code than I'd like, but it will probably work.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I think this link might be all you need: http://www.baldyweb.com/Requery.htm

  5. #5
    Pamela12375 is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Posts
    1

    Also fixed "accmdcopy not available now" error

    Thanks, RuralGuy! I wasn't a member of this forum but I searched my error message on the web and found your suggestion and link above and it fixed my problem as well! Thank you so much!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're very welcome and welcome to the Forum.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-13-2010, 10:50 AM
  2. "Next" Command button.
    By vCallNSPF in forum Forms
    Replies: 8
    Last Post: 01-20-2010, 04:26 PM
  3. "There was an error executing this command"
    By rnichols86 in forum Access
    Replies: 16
    Last Post: 11-18-2009, 06:56 PM
  4. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 AM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 PM

Tags for this Thread

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