Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1152
  • Last Modified:

How Copy a Record in a Table without getting PasteAppend error message?

I have a form bound to a table.  When I select a record I want to be able to copy that record as a new record in that table.  So I've created a button on the form and in the OnClick event I have...

    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdCopy
    DoCmd.RunCommand acCmdPasteAppend
    DoCmd.GoToRecord acDataForm, "frmClasses-edit", acLast

But I get an error when I click the button which reads "The command or action 'PasteAppend' isn't available now"

Help!
0
SteveL13
Asked:
SteveL13
2 Solutions
 
dannywarehamCommented:
You can surpress errors:

DoCMd.SetWarnings(False)

0
 
SteveL13Author Commented:
That didn't work. Still getting error.  Still can't copy (append) the record to the table.

0
 
LambertHeenanCommented:
I would imagine that the reason for the error is that you are pasting the primary key inot the enw record as well. The key cannot be a duplicate, so Access complains.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Jokra_the_BarbarianCommented:
Has to be something with your form's record source. Need some more info.
1. Version of Access.
2. mdb or adp?
3. Linked or local tables?
4. What is your form's record source? Query string, query, table?
0
 
dbase118Commented:
Try....

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.GoToRecord acDataForm, "frmClasses-edit", acNew
DoCmd.RunCommand acCmdPasteAppend

Your copy and paste were next to each other with no movement to the new area to copy
0
 
SteveL13Author Commented:
Now the new error is that I can't go to the specified record.

?
0
 
SteveL13Author Commented:
In answer to Jokra:

1. Version of Access.  2003
2. mdb or adp?  .mdb
3. Linked or local tables?  Local
4. What is your form's record source? Query string, query, table?   Table

--Steve
0
 
Jokra_the_BarbarianCommented:
Double check your form's Allow Additions property, I'll bet it is set to 'No' when you're running that code. You can also try this:
    Me.AllowAdditions = True
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdCopy
    DoCmd.RunCommand acCmdPasteAppend
    DoCmd.GoToRecord acDataForm, "frmClasses-edit", acLast
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now