Duplicating a record

D

Darrell Childress

I have a form that contains a list of items for the users to select. The
source of the form is a table. Many times, the exact item is not listed
and I need the ability for the user to duplicate a record and then edit
it to create a new item. The records are PartNo, Width, and Length. The
user might need a part that is 10" Wide x 98" Long, but that part does
not exist. So, I created a "duplicate" button so the user can "copy" a
piece, say 10" Wide x 96" Long and then edit the PartNo (primary key)
and Length. Whenever the user clicks on the Duplicate button, a new
record is created identical to the chosen record, but I get the
following error message

Run-time error '3058'
Index or primary key cannot contain a Null value

I simply click "End" and everything is okay (I must change the PartNo
field of course), but I can't figure out why the error message keeps
appearing.
 
J

John Vinson

I simply click "End" and everything is okay (I must change the PartNo
field of course), but I can't figure out why the error message keeps
appearing.

Please post your code. It sounds like a timing problem - the new
record is being created before its PartNo is assigned.


John W. Vinson[MVP]
 
D

Darrell Childress

The code is:

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
 

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

Top