By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,553 Members | 851 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,553 IT Pros & Developers. It's quick & easy.

Copy Record using selected fields on Form

P: 3
There are two fields I need to copy preferably using a command button. If possible I would also like to stipulate how many new records I want.

I've made a start using the in built Duplicate Record function but can't work out what needs to be ammended.

Any help would be appreciated.

Expand|Select|Wrap|Line Numbers
  1. Private Sub CmdDuplicateRecord_Click()
  3. On Error GoTo Err_CmdDuplicateRecord_Click
  5. Dim txtStockCodeNo As String
  6. Dim txtFixtureNumberCom As String
  8. Dim dbs As Dtabase
  9. Dim rst As Recordset
  10. Dim i As Integer
  13. 'Following Duplicates ALL fields - from in-built duplicate record "Wizard" function in Access
  14.     DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  15.     DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
  16.     DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
  18. Exit_CmdDuplicateRecord_Click:
  19.     Exit Sub
  21. Err_CmdDuplicateRecord_Click:
  22.     MsgBox Err.Description
  23.     Resume Exit_CmdDuplicateRecord_Click
  25. 'How to duplicate two specific Text fields? eg StockCodeNo and FixtureNumberCom
  26. 'How to duplicate any number of these?
  28. End Sub
Sep 12 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 14,534
Creating duplicate records is normally what you try to avoid. You say you want to duplicate just two fields in new records. Does the table have a primary key?

You will need to give a lot more information about what you are trying to do and why for us to be able to advise you.
Sep 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.