Creating Duplicate Record button help

G

Guest

I am writing code to put in a button OnClick event that will duplicate a
record. A user navigates to a record in the NewPartInputfrm that he wants to
duplicate then clicks a Duplicate button, which opens the
CreateDuplicateRecord form. The user completes The Model and New Part NHL
fields in the CreateDuplicateRecord form then clicks the AddRecord button,
which opens the NewPartInputfrm to the record he had navigated to. That
record is copied and pasted with the Model and New Part NHL fields populating
from choices in the CreateDuplicateRecord form. This works perfectly.

However, I have a multiple 3 field primary key in the NewPartInputfrm
(Model, New Part NHL and Part). All three fields are completed, but when I
try and click anywhere on the newly created record, the msg, "primary key
cannot contain a null value" appears. I've tried to requery, refresh and
me.dirty = false the newly created form and get the same message with
everything I try. Any ideas how I can fix this? Thanks you.

DoCmd.OpenForm "NewPartInputfrm", , , , acFormEdit
With DoCmd

.RunCommand acCmdSelectRecord
.RunCommand acCmdCopy
.RunCommand acCmdPasteAppend
End With
Forms![newpartinputfrm]![model] =
Forms![CreateDuplicateRecord].[ChooseModel]
Forms![newpartinputfrm]![New Part NHL] =
Forms![CreateDuplicateRecord].[NewNHL]

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Me.RecordsetClone 4
Public Sub Help 3
Delete button dode 4
Search for previous or next record 2
Delete and go to previous record 1
Delete button and refresh 8
Copy one field to new record 4
Run Code 3

Top