473,395 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Copy Record using selected fields on Form

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
1 2452
MMcCarthy
14,534 Expert Mod 8TB
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

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

Similar topics

1
by: Sean Howard | last post by:
Dear All, As is my want I need to do something in Access that seems simple but cannot fathom out. I have main form with two subforms, both datasheets with an almost identical table structure....
7
by: Megan | last post by:
Hi everybody- I inherited a database that somehow uses a bound combo box as a record selector. Let me give you some background. The form is based on data from 2 tables. The first table, Person,...
19
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
2
by: josephm | last post by:
Hello Group: My first post on the group.Hope I get a response. I have a modest Fire Insurance ACCES Db.Thanks to this group - for the code. A "wanna be programmer"... "LEARNS" The code...
5
by: Kaur | last post by:
Hi, I have been successful copying a vba code from one of your posts on how to copy and paste a record by declaring the desired fields that needs to be copied in form's declaration and creating two...
0
by: RobAMacAF | last post by:
Here is my prediciment. I have a database with a form. It in the people can pick a main category, then sub category, then it shows a list of questions from that in a sub form. I am trying to find a...
1
by: RobAMacAF | last post by:
Here is my prediciment. I have a database with a form. It in the people can pick a main category, then sub category, then it shows a list of questions from that in a sub form. I am trying to find a...
6
by: tonialbrown | last post by:
I was hoping that someone may give me some help in regards to writing some code. I have the following code that works - basically a user selects a record from a list box & it copies the fields...
1
by: lrw0831 | last post by:
I have the main form where employees enter "issues". Some issues have fields that are the same. My fields are Issue ID (auto) Product Entered BY Issue Type Priority Request from Status...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.