Asked by:
Access 2013 - Error msg: "The command or action 'Paste' isn't available now"

Question
-
I've created an application on a PC. I've got 30+ forms and I have added a "replicate record" button on all the forms to copy the open record as a new one to speed data entry. The button worked as expected, everywhere. I moved the application onto a server for a test in a multi-user environment. I currently have 5 interested users. It all seems to work except the "replicate record" button produces the error message above, on every single screen, every time. This has crippled deployment and I'm disappointed to be stuck here after 100s of after-hours work to create this application.
I am a new Access user hoping to reach an intermediate level of understanding of this software this year, so writing code is not a strength yet. So, if the answer is adding code somewhere, baby-step instructions would be most helpful. Thanks so much.
Tuesday, March 21, 2017 2:50 PM
All replies
-
I'm not sure what's wrong, but I can think of three avenues to pursue:
First, how did you create the button? Was it through the command button wizard, or did you write your own code or macro? What is the code/macro behind the button?
Second, have you verified that you can add records normally through the form?
Third, are you sharing the single database on a network share, so that all users are opening the same database in Access? If so, you should know that this is not the ideal way to share a database, and is subject to a number of issues. The recommended way is to split the database into a back-end database (containing only the tables) and a front-end database (containing everything else, with linked tables pointing to the tables in the back-end). Then every user gets their own copy of the front-end, to keep on their own PC.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.htmlTuesday, March 21, 2017 4:38 PM -
Rather than copying and pasting, a better way to carry data forward would be to set the DefaultValue property of each relevant control to its current value as this does not initiate a new record, but merely sets the defaults for when the form is moved to a new record. The record will not be initiated until the user edits one or more of the values or inserts a value into another control. Consequently values which make up a composite candidate key can be carried forward, and, provided that the user edits one or more of these values so that the unique index which defines the candidate key is not violated, no error will be raised. It also allows the user to abort the insertion of a new record simply by closing the form before editing any of the defaults or inserting additional data.
First set the Tag property of the relevant controls to CopyMe or similar. The code for the button's Click event procedure would then be:
Dim ctrl as Control
For Each ctrl In Me.Controls
If ctrl.Tag = "CopyMe" Then
ctrl.DefaultValue = """" & ctrl & """"
End If
Next ctrl
' add the following line if you want the form to automatically
' go to the new record when the button is clicked
DoCmd.GoToRecord Record:=acNewRec
This will carry the values forward to each new record in the current session until cancelled, which you can do with:
Dim ctrl as Control
For Each ctrl In Me.Controls
If ctrl.Tag = "CopyMe" Then
ctrl.DefaultValue = """"""
End If
Next ctrl
Note that the DefaultValue property of a control is always a string expression, regardless of the data type of the column to which the control is bound, so should be wrapped in literal quotes characters, each of which is represented by a pair of contiguous quotes characters, as in the above code.
You might like to take a look at Defaults.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to amend the form design accordingly.
If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
This little demo file illustrates means of electively carrying values entered in a new record forward, either in the current session only or in subsequent sessions also. In the latter case the defaults are stored in a separate Defaults table from which they are retrieved in subsequent sessions.Ken Sheridan, Stafford, England
Tuesday, March 21, 2017 11:55 PM