Results 1 to 14 of 14
  1. #1
    simon238 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    7

    One lookup to pull through multiple fields

    I'm fairly new to access and this is the first real problem I've encountered - surprisingly I couldn't find an answer on here/yahoo answers etc.



    I have Suppliers, Products and Purchase Order tables.

    In the purchase order I have the following fields, PO Number, Supplier, Product, Unit Price, Unit, Qty Ordered, Total Cost.

    I want to be able to select the product from the Product table, and then automatically pull through the corresponding unit price and unit, however I can't seem to find out how to do this without having to add a manual lookup to all fields. In which case I may aswell put them in manually.

    I imagine this is a fairly common requirement and easy to solve, but it's left me stumped.

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Please post a jpg of your Tables and Relationships.

    Do you understand queries?

  3. #3
    simon238 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    7
    Ok, so have tried to show example with 2 versions of the same form. Basically when I select the product I want it to automatically fill in some other fields which relate to said product.

    Click image for larger version. 

Name:	access.jpg 
Views:	10 
Size:	49.9 KB 
ID:	10170

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Can you get a screen print of your Relationships window? You have to have your tables set up to do what you want before getting into the Forms.

  5. #5
    simon238 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    7
    Relationships are as follows

    Click image for larger version. 

Name:	access2.png 
Views:	8 
Size:	34.8 KB 
ID:	10171

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

  7. #7
    simon238 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    7
    This level of complexity seems like overkill to me, would all these tables really be necessary?

    Take the first scheme for example, for user input would the form for adding a new order to the database include fields from both Customer_Orders and Order_Items?

    Going back to my original problem, I understand how this would then bring through from the product_id the product name. But how could I make this pull through more than one field?

    i.e. The user puts in the customer, and the product purchased, on selecting purchased product I would want the form to display the current price to the customer then user would input quantity purchased. Upon which the total cost would be calculated, displayed to the user and then stored in the order table.

  8. #8
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    All the tables from the models are not required. They were meant to show you some of the things that could exist in a model of Customer and Product/ Customer and Order etc. and how the things might be related.
    Your situation may be different and require different structures and relationships. These existing models are used as guides/references. They are NOT NECESSARILY meant for wholesale adoption, nor are they meant as the ONLY way to do something.

    Be cautious not to confuse WHAT you are dealing with, with HOW you will do it. In my experience the key is to get the Tables and relationships established, test the set up with sample data (good and bad) and check that the model will let me deal with the data at the level I need. Then work on HOW you may enter data, and How you may retrieve data.

    You should research Normalization and Entity Relationship Diagramming to get your tables and relationships designed.

    Here are some documents and videos related to Database and Access. I hope you find them useful.

    Principles of relational Design http://forums.aspfree.com/attachment...2&d=1201055452
    Entity Relationship Diagramming http://www.rogersaccesslibrary.com/T...lationship.zip

    Video tutorials:

    These are quite good for learning by Watching/Listening rather than reading.

    Logic Data Modeling 1 - Introduction - YouTube Logical data modeling

    Logic Data Modeling 2 - Candidate Key - YouTube Candidate key

    Logic Data Modeling 3 - Normalization - YouTube Normalization

    Logic Data Modeling 4 - Normalization Example - YouTube Normalization example

    Logic Data Modeling 5 - 1st Normal Form - YouTube 1st Normal form

    Logic Data Modeling 6 - 2nd Normal Form - YouTube 2nd Normal form

    Logic Data Modeling 7 - 3rd Normal Form - YouTube 3rd Normal form

    Logic Data Modeling 8 - Entity Relationship Diagram, part 1 - YouTube E_R Diagramming

    Complete set of tutorials on Acc2010.
    https://www.youtube.com/playlist?lis...FoilxbUY0yUqZP

  9. #9
    simon238 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    7
    Thanks a lot for the tips, very interesting read. I see now my approach is wrong and I am still too influenced into thinking in a way that I would use Excel. I will take this back to the drawing board

  10. #10
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Well, part of your learning curve will be dealing with unlearning some of the practices you learned with Excel/spreadsheet.

    Watch the videos. I can assure you that the key to database is getting the tables and relationships designed. If the structures and relationships are not "right", you'll waste unbelievable amounts of time trying to code around a structure problem -- basically trying to work against the DBMS.

    Good luck with your project -- let us know how you're doing.

  11. #11
    simon238 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    7
    I have now set up the tables in a way I think fits in with what I read on your suggested reading. However, I am wondering if there should ever be a loop throughout the diagram?

    I am also confused now how I would put this into one entry form, I assume using a query would be the way to set this up, but when I am selecting say employee, the only drop down box is from the foreign key and is there unique ID, which means nothing to the user. Also then it doesn't seem to pull through their name, and other attached data.

    Click image for larger version. 

Name:	access3.png 
Views:	5 
Size:	61.0 KB 
ID:	10211

  12. #12
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Is the Supplier the organization/person that provides the Product?
    If so, then remove the relationship between Supplier and Order.

    see this model (it's more detailed/complex than yours, but Supplier is not directly related to Order)

    The Supplier is related to the Product.

    http://www.databaseanswers.org/data_...ders/index.htm

  13. #13
    simon238 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    7
    The problem is the some products are available from more than one supplier so not listing supplier attached to the order could be confusing

  14. #14
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Please explain what Order means in your business.

    Customer Orders Products (from you)

    or You (the Business) Orders Product from Supplier

    I suggest the Supplier supplies Products to you.
    and the Customer orders Products (as OrderItems) from you.

    If you need to know which Supplier supplied a specific Product, and a Product could have been supplied by many Suppliers, then make a junction table Supplier_Product between Suppliers and Products.
    You will need a FK to Supplier and a FK to Product. and the OrderItem would be a record from this Supplier_Product table.(and drop the relationship between Product and OrderItem)

    (untested)

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

Similar Threads

  1. Lookup Fields
    By ericjsr in forum Programming
    Replies: 2
    Last Post: 07-16-2012, 09:15 AM
  2. Multiple fields to the same Lookup Table
    By igooba in forum Database Design
    Replies: 9
    Last Post: 01-03-2012, 04:14 PM
  3. Replies: 3
    Last Post: 12-16-2011, 02:37 PM
  4. Lookup Fields
    By mikel in forum Access
    Replies: 3
    Last Post: 03-03-2010, 07:56 AM
  5. Replies: 0
    Last Post: 12-19-2006, 09:44 PM

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