Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Copy and PasteAppend become unavailable

Status
Not open for further replies.

rosansky

Technical User
Jun 18, 2003
3
US
Hello...I am trying to Copy and Paste with VBA code:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
Me.AllowAdditions=True
DoCmd.RunCommand acCmdPasteAppend

Sometimes it works, but usually I get an error message "Run-time error '2046': The command or action 'Copy' isn't available now". (Sometimes the error occurs on PasteAppend.) Once this happens Access doesn't shut down properly. Even IF the database window closes, the Windows Task Manager indicates that the MSACCESS.EXE process hasn't ended. And until I end the process I can't even copy or paste in other Office applications, such as Word.

I've tried the code on other computers (a couple times) and haven't received the error.

Can anyone tell me why I'm getting this error? Is it the code, Windows, Clipboard, hardware, or what? And what can I do about it?

Any help is appreciated!
 
Hi rosansky,

Are you setting the focus to the record that you want to copy first. If say you're running this from a button, Access will think you're trying to copy the button and you'll get the error above.

Me!Mycontrol.Setfocus

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
Me.AllowAdditions=True
DoCmd.RunCommand acCmdPasteAppend

Bill
 
Hi Bill,

Thank you so much for your post!!

Is that appropriate for copying a full record with multiple fields? Now I'm getting "Run-time error '2465': Microsoft Access can't find the field referred to in your expression".


Here's the "full" story... this code is on a form which displays records from a table. My goal is to copy the record which is currently displayed, and add the "clone" to the table, changing the primary key fields. Here's the full routine:

---------------------------------------------------------
Private Sub cmdClone_Click()
Dim stTemp As String
Dim stEntryID As String
Dim rstDev As DAO.Recordset, rstAll As DAO.Recordset

On Error GoTo Err_cmdClone_Click

Set rstDev = Me.Recordset
Set rstAll = CurrentDb().OpenRecordset("__tblCases", dbOpenDynaset)

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
Me.AllowAdditions = True
DoCmd.RunCommand acCmdPasteAppend
Me.Test_Case_Id = "Unassigned"
stTemp = Me.Entry_Id
Me.Entry_Id = "Clone" & stTemp
stEntryID = Me.Entry_Id
Me.Status = "Pending"
Me.Analyst_Name = "Clone"
Me.AllowAdditions = False
If MsgBox("Your clone has been created, and can be accessed in the editing form." & _
(Chr(13)) & "The new Entry ID is: " & stEntryID & "." & _
(Chr(13)) & (Chr(13)) & "Would you like to work on " & stEntryID & " now?", vbYesNo) = vbYes Then '***go back and add more detail
DoCmd.Close acForm, "frmDownload"
DoCmd.OpenForm "frmCaseEntry", , , "[Entry ID] = " & "'" & stEntryID & "'"
Else
Me.Requery
Me.Refresh
End If

Exit_cmdClone_Click:
Exit Sub

---------------------------------------------------
The odd thing is that it HAS worked as intended a few times, but it usually hoses my clipboard.

Thanks again, Bill, for your help thus far.
Michelle
 
Hi rosansky,

This would be too time consuming to attempt to reproduce here. If you want send me a zipped up copy of yourd DB, removing any sensitive data first.

I'm sure it will be something quite obvious and will post any suggestions here ASAP.

Bill
 
Bill, it will take me a little time to remove the "good data", and I probably can't get it to you today. (I'm juggling a couple deadlines at the moment.) It will most likely be next week, unless I find a solution before then. I will let you know.

Thanks again!!!
Michelle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top