General discussion


Insert a Duplicate record in Access

By khimshar-rates ·
Using Access 2003 to create a stock control system for use by non PC literate users
I have a form/sub-form and have a need to add duplicate records (based on wherever the cursor is) to reduce actual typing by those persons.

How do I write a mcro/module whatever to do the equivalent of the Access commands...........
<Select Record>
<Paste Append>

Whilst I can get by quite well using the commands offered by M/Soft I struggle with VBA or anything like SQL

I eventually just want a button on the form that says 'Insert duplicate'

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

You could...

by jdmercha In reply to Insert a Duplicate record ...

build an update query to append the current record to a table. I don't know that that is the best way, but it should work.

Collapse -

by pswathi26 In reply to Insert a Duplicate record ...


I saw your post regarding the duplication of records. I am facing a similar problem(but I want this to be done using vba rather than queries)and I want to know if you solved your problem, if so how? Please let me know.

Below is a description of the problem that I am facing

I am using command buttons in my form in MS ACCESS 2000 to perform save and to duplicate values. However, when I open/run my form and start filling the data and press 'duplicate command' button, I got these errors.

Yesterday it said
'The Command or action 'Copy' not available'

and today it is showing me this error :
'The Command or action 'Paste' not available'.

However, yesterday 'Paste' worked fine. I am not sure what is going on with mu Access. Can you please let me know what is happening....

The code for duplicate command button is shown below.
Private Sub Duplicates_insert_Click()
On Error GoTo Err_Duplicates_insert_Click

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste

If Me.Dirty Then
DoCmd.RunCommand acCmdUndo
End If

Exit Sub

MsgBox Err.Description
Resume Exit_Duplicates_insert_Click
End Sub

I also tried to save the record first before copying, but I am still getting the same error for 'paste'. The only modification that I did for my code is added a new line with the code

DoCmd.RunCommand acCmdSaveRecord

I also wanted to mention that the code that I used(without save) does work for a particular database(same form that I described before) if it is not saved as a data file/MS access application and just saved as a file.

Can you please let me know if I am missing something here. If so can you please explain me as what I should do as I am new to VBA and Access.

Thanks in advance.I really appreaciate your help

Collapse -

Similar problem

by dawgtx In reply to Insert a Duplicate record ...

I have a form that has 20 fields in it, and approx. 12 of those fields will be duplicated for 20-30 records. Followed by changing the data in those 12, and then duplicating the next 20-30 records. What would be ideal is a "Create similar record" button that would fill the data for the 12 duplicated fields, and leave blank the remaining 8, and let the end user change as necessary.

Any ideas?

Collapse -

Use command button

by sstiles In reply to Insert a Duplicate record ...

If you are trying to duplicate a record from the same form you should be able to place a button on the form. Select Record Operations... Duplicate Record... and name it whatever you want. When you click the button it will add a new record with exactly the same information. You would have to change some value in the key if you are not using an Autonumber field when creating a new record.
If you are using another form then you would have to do an insert in VBA based on the current fields.

Hope this helps.

Related Discussions

Related Forums