473,394 Members | 1,797 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/Transfer records from main and related tables/forms

stonward
145 100+
Hello again everyone,

I have a quotations form (main and subform) based upon two related tables. I want to be able to convert the quote to a sale and thus transfer the records to my Order and Order Details tables/forms.

Copying over the main table is straightforward enough, but I'm damned if i can get the related records copied. What is the best method of solving this?

Thanks in advance,

StonwardR
Aug 23 '12 #1
4 2320
twinnyfo
3,653 Expert Mod 2GB
Stonward,

My recommendation may throw you for a loop. I would not transfer the records! I would add a Yes/No field to your table that indicates whether the record is a quote or a finalized order. Then you don't have to transfer records, and you can use the same form/subform combination.

I do see one hitch with this, and that is that if you need to maintain historical records of your quotes vice your orders, it may be a problem.

To follow your method, my first question would be, what is the code you have tried and are you getting any errors? If both sets of tables have primary key indexes that are autonumbered, it may cause some problems with copying over your records, because the two tables would be looking for different indexes with which to relate themselves to (or they records could get mis-aligned. In this case, you would want to make sure that each quote has a distinct OrderNumber that YOU generate when the record is created, so that when you transfer the records, you search on that distinct field, rather than a primary key.

Hope this made sense..... Hoep even more that it helps!
Aug 23 '12 #2
stonward
145 100+
Thanks Twinnyfo,

I've been thinking about your initial suggestion about merely adding a 'This is now a sale' option to the Quote forms....I'm not with my (database) baby at mo, but that sounds like an idea - and not one I'd have thought of. I've tried all sorts of loops and SQL insert and update statements, all to no avail (though one time the code added some 89,000 records on the detail side, all of the same product!

Will let you know asap. Thanks again,

StonwardR
Aug 23 '12 #3
twinnyfo
3,653 Expert Mod 2GB
I would use a recordset in VBA. First ID the record from the main table, then create a recordset from the second table that only matches that record. Create a second recordset to add to the main table, add that one record. Then a third recordset to add the records from your first recordset. Sounds like a lot of work but it's actually quite simple.

Let mne know what you come up with....
Aug 23 '12 #4
NeoPa
32,556 Expert Mod 16PB
Information provided is a bit skimpy, but I'll reply to what's there. Feel free to work with that, or post the relevant details and we can be more specific with the assistance.

First off, as much as possible, you want to ensure that all data changes are treated together as a single transaction. Transactions in database work are a very important concept if you don't want data to get out of step and essentially inconsistent.

You also need to take into consideration any table requisites for the data. EG. Tables are often set up such that a record on the one side of a One-to-Many relationship must exist before any matching records on the many side. Thus the following steps must be ordered appropriately if they are to work reliably.

As there is no reason not to, and it typically works more efficiently when you do so (as well as requiring fundamentally less code), SQL action queries are the best course for applying the updates you need.
  1. Create copies of your [quote] records (Typically only the one but can be more in some circumstances) in your [Order] table.
  2. Create copies of your [QuoteDetail] records in your [OrderDetail] table.
  3. Delete all records that were copied in step #2, from your [QuoteDetail] table.
  4. Delete all records that were copied in step #1, from your [quote] table.
  5. If, and only if, all these steps have completed successfully then complete the transaction.
    Otherwise, take steps to leave the system as you found it and leave a message for the user that the process failed (and why).
Aug 23 '12 #5

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

Similar topics

3
by: William Gill | last post by:
I can't help but think I'm re-inventing the wheel if I have to code my own interface! Isn't there some script, php code, or something (modifiable / customizable) available that lets me select...
3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
0
by: Jonathan Fisher | last post by:
Whatıs the appropriate way to create records in related, subsidiary tables when a record is created in a main table? Iım using Access 2000, and I have a main table called tblProject, and a few...
2
by: Support | last post by:
Is it possible to add a record in one table and have Access automatically add date from one of the fields into another table?? In more detail: Table1 has the following fields: Product_ID,...
3
by: Leinad Kong | last post by:
I'm using Access 2002, as front-end and back-end as well: 1) I faced database corrupted problems, when more than 1 user edit concurrently. I'm using All-records Locking, and open-exclusively as...
1
by: Christa Waggett | last post by:
Hi, I'm not a programmer but would appreciate some help with the following. I've been looking at various sites but cannot find the information I require. I have a table of strata plans and if we...
4
by: HLCruz via AccessMonster.com | last post by:
I am working with a database that has client information separated in to 4 related tables - tFolder, tAddress, tEmail, tPhone number. In addition there are related tables tGifts and tCalls. The...
5
by: upwardgazing | last post by:
I'm using Access 2003 (Access 2000 file format) and I have two tables related one-to-many called tblTempEncounter and tblTempEncounterDetails. I need to move a record from the first table with it's...
3
by: simple simon | last post by:
How would I insert into multiple related tables using a table valued parameter? Is there any way to do this without using a WHILE loop? I know how to insert from a table valued parameter into one...
9
by: TrueMan2010 | last post by:
Hi All, I need to insert new records in existing Tables of Access. The two tables are related by Primary and Foreign key relation. The new data to be imported is in Excel sheet which I have...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.