Results 1 to 6 of 6
  1. #1
    CodLiverOil is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Posts
    13

    Exclamation Getting in a muddle with relationships

    Hi - Help!!

    I want to add functionality to a database, I wan't to be able to split ordered items between several dispatches.

    I have the following tables:

    tblOrders
    • OrderInternalID (AutoNumber, PK)
    • OrderNumber (Indexed, Unique)
    • Department
    • StaffName


    tblOrderItems
    • OrderItemInternalID (AutoNumber, PK)
    • QuoteNumber
    • ItemRef
    • ItemName
    • QuantityRequired


    tblOrders has a 1-to-many relationship to tblOrderitems using QuoteNumber


    The above works fine, until we get to an Item where we want to send the QuantityRequired out in two or more deliverys, so to tblOrderItems I have have added QuantityDeliveredand added two new tables:

    tblDeliveries

    • DeliveryRef (AutoNumber, PK)
    • DeliveryDate


    tblDeliverItems
    • InternalID (PK)
    • DeliveryRef
    • OrderItemInternalID
    • QuantitySent


    While I can see that tblDeliveries will have a one-to-many relationship with tblDeliveryItems using DeliveryRef, I can't fathom out how tblDeliveries will get it's relationship to the items being delivered.

    How I wan't it to work is that when an Order is created, with many Order Items, the user clicks a button for delivery on that order, and is asked for a Delivery ref (tblDeliveries.DeliveryRef) and date (tblDeliveries.DeliveryDate) and then is shown each item in that order and asked how many of each are being delivered.

    If I connect tblDeliveries to tblOrderItems then I think that will cause each item in an order to have a different DeliveryRef
    If I connect tblDeliveries to tblOrders I can't see how it will be able to reference the objects in tblOrderItems

    Am I making this too complicated for myself or over thinking it? head is now fried and I am quick running out of notepad paper trying to draw down relationships!! please send help.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    if you want to keep the deliveres/deliveritems table setup I would include the OrderInternalID in the tblDeliveries table, this would help you pick out which order items you delivered on a particular order. Other than that I don't see a reason your current setup wouldn't work. I might also encourage you to use the PK OrderInternalID from your table tblOrders in your tblOrderItems table if you aren't (I can't tell by your nomenclature).

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  4. #4
    CodLiverOil is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Posts
    13
    I still can't get this to work:

    This is my relationships view:
    Click image for larger version. 

Name:	databaseRelationships.JPG 
Views:	11 
Size:	37.9 KB 
ID:	19621

    If I create a form frmOrders, with a subform frmOrderItems that works as expected, if I create three records in the table tblOrders I can cycle through them in the form and add records to the subform that are correctly linked to the main form.

    But I cant get a form or query to work for me.

    In English, what I (think) I have is this:

    tblOrders contains the Order Number(it will also contain the staff member name and department but they are later)
    tblOrderItems contains the individual items ordered
    tblDelivery contains the delivery reference and date of a particular delivery
    tblDeliveryItems contains the quantity of each item (from tblOrderItems) that is being sent in a particular delivery.

    The form I want to create will show at the top, the order number (tblOrders.OrderNumber) Delivery Ref (tblDelivery.DeliveryRef) Delivery Date (tblDelivery.DeliveryDate) and in a subform, in datasheet view, the Order item deetails (tblOrderItems.ItemDetails, tblOrderItems.QuantityOrdered, tblOrderItems.QuantityDelivered and tblDeliveryDetails.QuantitySent)

    So the user goes to their OrderNumber, enters the DeliveryDate and DeliveryRef and then in the subform, next to the items from the Order, they enter how many of each item they have had (that then updates the tblOrderItems.QuantityDelivered)

    I think I know where I am going wrong, the table tblOrderItemDetails has a 'many' relationship to the table tblOrderItems so I can't show it on the same datasheet???

    But as each order can have many order items, and each order can have many deliveries, how do I get around that??? head is well and truly muddled!!
    Last edited by CodLiverOil; 02-07-2015 at 11:46 AM. Reason: Updating on results

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    Try separating your Orders form/subform and your Deliveries form/subform. If you are going to try and cram them all on the same form (even with a tabbed control) you're going to experience quite a few problems.

    I do not use bound forms so I do not know if this is possible but you could also try this:

    Main Form Contains tblOrder Information
    Subform OrderItems contains tblOrderItems information
    Second Subform contains tblDeliveries (multiple deliveries per order)
    A subform within the subform tblDeliveries (multiple items per delivery)

    Just bear in mind that if you do this as subforms of your form that contains the tblOrders information everything you see relating to deliveries will be related to the order, in other words you would have to cycle through orders to try and find a specific delivery number or have a fairly complex 'search' function.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    See the free model here and see if it or parts of it can help resolve "the muddled-ness".
    Also, review these business rules associated with the model.

    An Order contains 1 or Many Items
    A Delivery (or Shipment) contains Items which may or may not be for a complete Order
    (This model allows for partial shipments/deliveries)

    Also, get your tables and relationships set up to meet your business requirements; test the model and refine as necessary. When your model and test data are "working", then move to forms and interfaces.

    Good luck.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Explicit Relationships and Implicit Relationships
    By Dazza666 in forum Database Design
    Replies: 2
    Last Post: 07-17-2013, 02:11 AM
  2. Many-to-Many Relationships
    By African in forum Database Design
    Replies: 10
    Last Post: 06-24-2013, 09:35 AM
  3. Relationships
    By teza2k06 in forum Database Design
    Replies: 1
    Last Post: 03-08-2013, 03:23 PM
  4. One to many relationships
    By CoachBarker in forum Database Design
    Replies: 1
    Last Post: 09-13-2010, 09:01 PM
  5. Too Many Relationships
    By MikeT in forum Database Design
    Replies: 4
    Last Post: 08-25-2010, 07:23 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums