Here is some very rough 'air code' (typing on-the-fly, not tested). See what you can do with it.
Code:
Sub AppendOrders()
Dim strOldOrderID
Dim intNewOrderID
Dim strOrderItemID
Dim booFirst As Boolean
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM Amazon_orders ORDER BY OrderID, OrderItemID;"
strOldOrderID = rs!OrderID
booFirst = True
While Not rs.EOF
If strOldOrderID = rs!OrderID Then
If booFirst = True Then
intNewOrderID = DMax("OrderID", "Orders") + 1
CurrentDb.Execute "INSERT INTO Orders(OrderID, CustomerID) VALUES(" & intNewOrderID & ", " & rs!CustomerID & ")"
booFirst = False
End If
CurrentDb.Execute "INSERT INTO OrderDetails(OrderID, OrderItemID) VALUES(" & intNewOrderID & ", " & rs!OrderItemID & ")"
rs.MoveNext
Else
booFirst = True
If Not rs.EOF Then strOldOrderID = rs!OrderID
End If
Wend
End Sub
If your OrderID in new table is not an integer but an alphanumeric structure, incrementing it will be a little more complicated. However, I just pictured a way this might be possible with queries. Want to provide a sample of the imported data? Follow instructions at bottom of my post.