I have just upgraded from MS Access 2013 to 2019 and my duplicate record buttons have stopped working. I get the error "The command or action Paste is not available now". Have looked through the Trust Center for anything that might be upsetting it but I cannot see anything. I created a new button using the Duplicate Record wizard, and that has the same problem. So it's not my code.
Private Sub Command115_Click()
On Error GoTo Err_Command115_Click
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste
Exit_Command115_Click:
Exit Sub
Err_Command115_Click:
MsgBox Err.Description
Resume Exit_Command115_Click
End Sub
CodePudding user response:
After several hours of hairpulling. I have arrived at a work around. Just putting a pause of point one second before the paste avoids the error message. So it seems there is some kind of timing issue. Might be some kind of record locking problem that only occurs on slower computers.
Private Sub Copy_Record_Click()
On Error GoTo Err_Copy_Record_Click
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
Pause (0.1)
DoCmd.RunCommand acCmdPaste
Exit_Copy_Record_Click:
Exit Sub
Err_Copy_Record_Click:
MsgBox Err.Description
Resume Exit_Copy_Record_Click
End Sub