Append query: order details from Excel to Access table (1 Viewer)

X

Xunil

Guest
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.
 

Tonyi

New member
Local time
Today, 11:49
Joined
Apr 14, 2002
Messages
7
To summarise, you have a list of parts, belonging to a single order, but when you pull the data in it wants to go as one item, one order.

Ie, you want a one to many relationship, but in fact you get a one to one.

Looking at tblOrderDetails you are using a unique record ID of OrderDetailsID. Every item within an order will generate a new OrderDetailsID.

The tables use this a the link, so will generate a new OrderID for every OrderDetailsID.

The value that is unique for an order is OrderID. If this is used as the link, then you will be able to have the one to many relationship needed.

Having done this you can remove the OrderDetailsID from tblOrders

Cheers
 
X

Xunil

Guest
Tonyi

Thanks for taking the time to reply.

I'm off to attempt the link you suggested and will post back with the results as and when I have any.

Thanks once more for your input.
 

LGOF62

LGOF62
Local time
Today, 03:49
Joined
Aug 13, 2007
Messages
10
looks like Tonyi cracked it. Seems strange to me that there are no dates involved or numbers of items in any of your tables?
 

Users who are viewing this thread

Top Bottom