Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

SKahle89

Chemical
Sep 25, 2008
15
0
0
US
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, it needs to be changed to make the record unique
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



 
Replies continue below

Recommended for you

Status
Not open for further replies.
Back
Top