How do I duplicate a record in access?

Marq

Well-known Member
Joined
Dec 13, 2004
Messages
914
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
I have a form where I have drop down menus which I use to load change orders for jobs. I am doing a lot of repetative entries per form. Most are identical choices except the date.

Is there a duplicate button that can be created on this form?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Maybe something akin to this:

VBA Code:
Private Sub copyrecordbutton_Click()
On Error GoTo Err_copyrecordbutton_Click
Dim txtOld1 As Variant
Dim txtOld2 As Variant
Dim txtOld3 As Variant
Dim txtOld4 As Variant

txtOld1 = txtcurrent1.Value
txtOld2 = txtcurrent2.Value
txtOld3 = txtcurrent3.Value
txtOld4 = txtcurrent4.Value

RunCommand acCmdRecordsGoToNew

txtnew1.Value = txtOld1
txtnew2.Value = txtOld2
txtnew3.Value = txtOld3
txtnew4.Value = txtOld4

  
Exit_copyrecordbutton_Click:
    Exit Sub

Err_copyrecordbutton_Click:
    MsgBox Err.Description
    Resume Exit_copyrecordbutton_Click
    
End Sub
 
Upvote 0
How many fields? That approach can get quite wordy (is that a word?).
If you're not copying over the PK, then sometimes this is enough
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdPasteAppend

Or you can clone the recordset, add new and loop through all the fields except for the PK field and update the clone.
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,462
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top