I have a form which has several subforms within it. I am trying to copy the record in the main and subforms and then post a duplicate record. This is because the record contains details of attractions and events and often there are new similar attractions and events and it will prevent the admin having to reenter the same details. I read up and found some code:
Private Sub Copy_Click()
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.GoToRecord , , acNewRec
DoCmd.RunCommand acCmdPaste
End Sub
This seems to do the copy and paste but then when I go to change the primary key (SKU) or any field it says "Update or CancelUpdate wthout AddNew or Edit" and I don't know what that means. I can only assume it is freaking out because of duplicate primary keys. My coding is not good enough to create code that updates the primary key. I tried adding the code below which is something I use elsewhere in the database but it says I am missing a = so either my syntax is wrong or there is another problem.
Private Sub Copy_Click()
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.GoToRecord , , acNewRec
DoCmd.RunCommand acCmdPaste
docmd.SetProperty ([sku],acPropertyValue,Left$(DLast("[SKU]","tbl_attraction"),1) & Format$(Val(Right$(DLast("[SKU]","tbl_attraction"),3)+1),"000"))
End Sub
So....im not sure this is the best way to do what I want to do. If it is then is this error because of the primary key or maybe because of the subforms? Any help appreciated.