DataBase - Copy selected records from two tables to two new tables

Asked By alhotch
31-Jan-10 01:12 PM
I have a database with two tables - tblOrders and tblOrderDetails.
Relationship of One (tblOrders) to-Many (tblOrderDetails) exists. tblOrders
has fldOrdersID as Primary Key and tblOrderDetails has fldOrdersID as Foreign
Key. As expected, the tblOrderDetails table can have more than one
corresponding record in the tblOrders table. I need to select records (based
on the fldOrdersID) from the tblOrders table AND "child" records from the
tblOrderDetails table to TWO NEW tables - I will call them tblCulledOrders and
tblCulledOrderDetails. This means I get a copy of the selected records ONLY,
in the new tables.

I have created an Append Query that selects the desired record from
tblOrders and places it in the tblCulledOrders table. However, I do not get
the corresponding "child" record from tblOrderDetails table to be placed in
the tblCulledOrderDetails table. I am not sure how to set up the queries and
relationships between (among ?) the two or four table to do this. Also, if
the tblOrderDetails table has more that one corresponding record to the
tblOrders table, Access appends two (or more) records to the tblCulledOrders
table after issuing a "key violation" message prior to performing the Append
Query operation.

Can this operation be done without writing any code (I quit writing code -
Fortran - years ago) ?
TblCulledOrderDetails
(1)
FldOrdersID
(1)
Database
(1)
Report
(1)
TblOrderDetails
(1)
TblCulledOrders
(1)
TWickerath
(1)
TblOrders
(1)
  Steve replied to alhotch
31-Jan-10 01:45 PM
Your append query with the appropriate criteria will append the order
records you want to tblCulledOrders. Note that you MUST do this first before
trying to append detail records to tblCulledOrderDetails.

To append detail records to tblCulledOrderDetails, you need a second append
query. The query needs to include tblOrderDetails and tblCulledOrders. Join
OrderID between the two tables. THis makes the query only return the detail
records that correspond to the orders in tblCulledOrders. Run the second
query and you will append all the detail records that correspond to the
orders in tblCulledOrders.

Steve
santus@penn.com
  KenSheridan via AccessMonster.com replied to alhotch
31-Jan-10 07:00 PM
This is not a good way of going about things, as you would be encoding data
(the fact that orders are culled) as a table name.  A fundamental principle
of the database relational model (the Information Principle) is that data is
stored as values at column positions in rows in tables and in no other way.

Notwithstanding this fundamental design flaw, you are making life a lot more
difficult for yourself than needs be the case.  All you need to do is include
a Boolean (Yes/No) column, Culled, in the orders table.  To 'cull' an order
you simply set the value of this column to True, which you can do via a bound
checkbox on a form or with an 'update' query if you want to cull a set of
orders simultaneously.

The order details table need not be changed as the related rows in it will
still be related to the rows marked as culled in the orders table.

For any forms or reports where you only want to see the active orders just
base the form or report on a query 'WHERE Culled = FALSE'.  In query design
view simply enter False in the 'criteria' row of the Culled column.
Conversely to see only the culled orders the criterion for the Culled column
is True.

Ken Sheridan
Stafford, England


--
Message posted via http://www.accessmonster.com
  Tom Wickerath replied to alhotch
31-Jan-10 07:03 PM
Rather than copy records to two new tables, cannot you simply add a Yes/No
field to your existing Orders table, with a default value of 0 (false) for


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
Create New Account
help
Library Database DataBase Firstly, I am not sure if Library database is the correct term. I am talking about Dbs to which you set a reference drew blanks last time. Now assuming I have several referenced (library?) databases in my main database, how do I get the names of all the forms in all the Dbs? CodeProject AllForms.Count gives me the correct number of forms if I am in that referenced database. What I think I need is a method of looping through all the different CodeProject names in the main database, but there is not a sort of CodeProjects parent object. Or somehow moving the focus And, No, there is not any parent object for all the code projects. Because each database only knows about its own objects (or documents), you have to use a procedure in each database to refer to the objects in that database. E.g. to open a form in
Might be outgrowing Access but daunted by SQL Server DataBase I am close to completing the consolidation of various small Access databases and a couple of Excel spreadsheets that my little company uses (5 staff) into an all encompasing Access database and I was planning on splitting the database when I was finished to allow simaltaneous use of it by staff on our small to me that I am going to need to give staff access to this new database from remote locations (outside of our office network). Two staff members are regularly overseas, one been playing around with trying to link tables from remote locations (ftp path of the database on our Network Storage Device at the office) and needless to say - that do not It all started when I came across a very encouraging article on keeping your Access database as your front end application and linking to SQL Server database tables. I am finding it MUCH more complicated than I had hoped. Can anyone suggest a simpler way of achieving remote access to my database? I have at my disposal a Network Storage Device which has remote access capabilities (this
Limit Records Shown Per Report DataBase Question I use a report to show all systems located at a specific customer. When a customer has more than 20 systems, I would like a new report to start with all the same information in the header, etc. Any suggestions?? I am with header repeated on each page. UNTESTED UNTESTED UNTESTED In your query that feeds the report add field - - ZZZ: 1 Use Ranking in a Group in follow-on query with \ 20 post helpful to you? Reply Top Tia 2 / 3 / 2010 8:39 AM PST My report is set up with all the header information on the report and then all the systems are listed on subreport. They are connected through Customer ID I place the code in the query for the subreport or the query for the report??? Click to show or hide original message or reply text. Was this post helpful to
SQL query slow DataBase Hi In the code below I found that it takes 1.3 seconds to load suited to handle databases beyond stamp collection size and lacks most features of a "real" database management system. Consider using a relational database, i.e. SQL Server Express, its free. Make sure to set primary key properties to to worry about problems like SQL injection attacks to you application. best, MiB. The JET database engine is often faster and more efficient than similar retrieval with SQL Server. And simply can be summed up as your general ignorance on the matter how = 20 computers and database engines function and operate in our industry. So your galactic stupidity and ignorance is well years - version 4 came with Office 2000. If JET is so vastly superior to regular database servers, kindly share the pearls of your wisdom and explain why companies like Oracle (guess rationale, but I am sure you will enlighten us. Can you also explain, please, why database client products like Sparxsystems Enterprise Architect using the same relational schema, same index structures, and to criticize an important MVP like you. Maybe this source is: http: / / databases.aspfaq.com / database / what-are-the-limitations-of-ms-acc = ess.html. I would like to humbly hint
Need to print Cover Sheet for report. DataBase Hi, I am using Access via Office XP Pro. I am working on a government report. The first page of the report is a cover sheet / instructions and has nothing to do with the actual data other than it has to be the first page / coversheet to the report. Then I have the actual report which needs to have one footer at the end of the report which has the actual totals. I do not need a footer on each page, just the last page. Currently, I put the cover sheet in the Report Header. The cover sheet has our name, address, phone number, name of person submitting the