Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appending products ordered from Excel into Access customer order table

Status
Not open for further replies.

Xunil

Technical User
Dec 17, 2002
27
GB
The thread title says it all. I'll try to be as thorough as I can with the outline of the problem.

I'm quite new to Access and I'm playing with a project for a friend who builds computers for a living. I've set up a mutli-sheet Excel workbook where different sheets list components, roughly divided by category (Build Components, Printers & Scanners, Networking, Portable devices and Software. Each sheet has the products listed under the following column headings; Product Category, Order Code (from his supplier) Description, Cost.

I've set up a series of mutli-column listboxes accessable from a user form with command buttons which allow him to select items from any of the above sheets and transfer them directly to the invoice sheet of the same workbook. There are formulas to calculate financial amounts based on his profit margin, VAT, quantity of items and so on. It all works beautifully.

Now here's the problem. I have created the relevant ranges on the spreadsheet to allow me to link the range into Access and I can easily create the necessary append queries to pull the information into the customer order table of the database. However, this is where I go horribly wrong.

The first range/append query adds the customer contact information (name, address, tel no, etc) to the customer table in Access. No problems. The third range/append query adds the total order cost and total order VAT to the order details table. No problems. The second range/append query adds the list of products under their Product Category, Order Code, Description and Cost columns, but no mater what I do or how I link the tables in Access, I end up with each individual product item being classed as a new order with its own Primary Key ID generated by Access.

My tables are;

1. tblCustomers (CustomerID, Name, Surname, Address1, Address2, Town, County, Post Code, TelNo, FaxNo, Email)

2. tblOrders (OrderID, CustomerID, OrderDetailsID) with CustomerID being the link between them.

3. tblOrderDetails (OrderDetailsID, OrderID, Product Category, Order Codes, Description, ItemCost) with OrderDetailsID being the link between this and tblOrders.

I've tried using text and memo fields to no avail. Logic dictates that I must somehow have the table relationships set up incorrectly which is preventing me from counting one customer order as having many items in the OrderDetails table. I'm totally lost here and would appreciate any and all suggestions (as long as they remain polite of course).

My apologies for the length of this question but I wanted to include as much details as possible. Thanks in anticipation.
 
I think that the problem is the type of relationship between your tables. I think both should be one-to-many. Your structure is very similar to the Northwind sample. You may want to take a look at it.

Wendy
 
Wendy

Thanks for offering your input. It more or less confirms my own suspicions.

I took a look at he table relationships and I think I can see where I have strayed.

tblOrders (OrderID, CustomerID, OrderDetailsID)

is currently linked to

tblOrderDetails (OrderDetailsID, OrderID, Product Category, Order Codes, Description, ItemCost)

using the OrderDetailsID. I think if I get rid of the OrderDetailsID field in tblOrderDetails and link the two using OrderID, I should get the one to many I am looking for to allow one order to consist of many items rather than each item to be classed as one order.

Thanks for confirming my suspicions and jogging me into some serious thought regarding the table relationships. I'm off to try it and will get back as and when I have any results.

:eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top