By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,455 Members | 2,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,455 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.
Bernard

Expand|Select|Wrap|Line Numbers
  1. Private Sub CmdDuplicateRecord_Click()
  2.  
  3. On Error GoTo Err_CmdDuplicateRecord_Click
  4.  
  5. Dim txtStockCodeNo As String
  6. Dim txtFixtureNumberCom As String
  7.  
  8. Dim dbs As Dtabase
  9. Dim rst As Recordset
  10. Dim i As Integer
  11.  
  12.  
  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
  17.  
  18. Exit_CmdDuplicateRecord_Click:
  19.     Exit Sub
  20.  
  21. Err_CmdDuplicateRecord_Click:
  22.     MsgBox Err.Description
  23.     Resume Exit_CmdDuplicateRecord_Click
  24.  
  25. 'How to duplicate two specific Text fields? eg StockCodeNo and FixtureNumberCom
  26. 'How to duplicate any number of these?
  27.  
  28. End Sub
  29.  
Sep 12 '07 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
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.