473,394 Members | 1,748 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,394 software developers and data experts.

Copy at specific record...

Hi,

I've been reading tons of posts on how to copy records, but to no
avail....i'm still stuck.

There are three tables: Main, Sub-Form1 & Sub-Form2

I have a form which displays some data.
The PK (ProductID) for each record on the form is an AUTONUMBER.
This form also has a sub-form, linked via ProductID. The subform also
has a PK for each record (subformID) which is an AUTONUMBER.
The form also has a button which links to another for via ProductID,
and which also has it's own AUTONUMBER PK.

So, I need to be able to select a record from the same table that feeds
data to the Main form, as I am trying to let users copy existing
products, and to then just make slight changes to various elements.

Firstly, I need to have a combo box, which would let me select the
product to copy. Then I would have to coy this product to a new
ProductID. Then somehow copy the subform data linked to that selected
product, whilst setting the new linked ProductID.

Confused..I am..

I'm sure there is a work around, but i've never done this
Appreciate all your help

David, uk

Nov 13 '05 #1
3 3189
You use append queries to do it. The catch is that you have to capture
the newly inserted Main table's primary key, and then you can
substitute that value on your future inserts.

You could use DMAX to get the last AutoNumber, but then you'll probably
want to wrap the whole thing in a transaction so you don't get the
wrong PK value because someone just slipped a record in just after you
did.

Nov 13 '05 #2
David, here's the general idea of how I'd do this, leaving out the actual
code for now.

1) using vb, create a recordset that is set to the data behind the main form
2) with vb, find the record you want to copy (using the PK from the combo
box)
3) insert a new record into this table, using the values from the record
above, with maybe "copy of Product Name" as your product name.
4) use vb to read the Product ID of the newly inserted record and store it
as a variable (be careful if there are multiple users)
5) set the main form to point to the newly created record, close this
recordset and create another based on the subform data table
6) in this new recordset, find each record that has the original PK from the
combo box and get it's field values, then insert a new record with these
values into the recordset (like step 3), but replacing the origingal Product
ID value with the new one you got in step 4
7) close this recordset and requery the subform

I hope this isn't too confusing and gives you a starting point for further
research.
-John
<da***@scene-double.co.uk> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi,

I've been reading tons of posts on how to copy records, but to no
avail....i'm still stuck.

There are three tables: Main, Sub-Form1 & Sub-Form2

I have a form which displays some data.
The PK (ProductID) for each record on the form is an AUTONUMBER.
This form also has a sub-form, linked via ProductID. The subform also
has a PK for each record (subformID) which is an AUTONUMBER.
The form also has a button which links to another for via ProductID,
and which also has it's own AUTONUMBER PK.

So, I need to be able to select a record from the same table that feeds
data to the Main form, as I am trying to let users copy existing
products, and to then just make slight changes to various elements.

Firstly, I need to have a combo box, which would let me select the
product to copy. Then I would have to coy this product to a new
ProductID. Then somehow copy the subform data linked to that selected
product, whilst setting the new linked ProductID.

Confused..I am..

I'm sure there is a work around, but i've never done this
Appreciate all your help

David, uk

Nov 13 '05 #3
Hello John,

Many thanks for your post.
I'm not sure how to do this in VB.
First I created a basic new record in the Products table to get a new
ProductID.
I then tried an append query to add the fields from the products table
from a specific product already listed to my new ID. I just got key
violation errors with anything I tried. I also read that you could not
append data that contains 'Null'. Nearly all my products have some
fields that contain Null entries ?

Appreciate your help again
Thanks so much

David :-)
John Welch wrote:
David, here's the general idea of how I'd do this, leaving out the actual
code for now.

1) using vb, create a recordset that is set to the data behind the main form
2) with vb, find the record you want to copy (using the PK from the combo
box)
3) insert a new record into this table, using the values from the record
above, with maybe "copy of Product Name" as your product name.
4) use vb to read the Product ID of the newly inserted record and store it
as a variable (be careful if there are multiple users)
5) set the main form to point to the newly created record, close this
recordset and create another based on the subform data table
6) in this new recordset, find each record that has the original PK from the
combo box and get it's field values, then insert a new record with these
values into the recordset (like step 3), but replacing the origingal Product
ID value with the new one you got in step 4
7) close this recordset and requery the subform

I hope this isn't too confusing and gives you a starting point for further
research.
-John


Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Svelte Poshy | last post by:
Copy the content of a field into another field In my table Customers i want to copy the content of the field "Employee" which is a text field, into the field MOL, also a text field I need to...
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
5
by: DraguVaso | last post by:
Hi, I need a SECURE way to copy parts of a file. I'm having files which contains a whole bunch of records. In one 'fysical' file I'm having one or more logical files. What I need to do is to...
0
by: igendreau | last post by:
I have a database with a Header table. Each record in tblHeader has two One-to-Many Relationships: with tblLines and tblKeys. The HeaderID field ties tblHeader to the other two tables. The data...
2
by: Swinky | last post by:
I hope someone can help...I feel like I'm walking in the dark without a flashlight (I'm NOT a programmer but have been called to task to do some work in Access that is above my head). I have...
1
by: new to access | last post by:
Im very new to access, how do I copy paste only a specific field and not any entire record? Specific fiel to specific field in another form.
1
by: Invicta | last post by:
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...
3
by: Richnep | last post by:
Hi all, I have tabbed subforms where I need to copy one field value from one subform over to another subform. Although I can run an update query to accomplish this I would like to do it through...
7
kcdoell
by: kcdoell | last post by:
Good morning everyone: I created a form and set the default view as a continuous form. Basically the form is displaying records in which the user can add or edit new ones. The record source for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.