Results 1 to 4 of 4
  1. #1
    Lorlai is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    107

    Question Access SQL syntax Reference other tables

    I am very very new to Access, and am trying to figure out the best way to create my database. I have experience in SQL, and find that much easier than the Access UI. I have two tables (Details and Manager) and am trying to create a foreign key reference so that these two can be together. For example, the Details Table looks like this:



    ProductID ManagerName OfficeNum OfficeAddress
    234 Sally Smith 56 123 Fake St
    789 Bob McBob 02 987 Cool Rd

    *I know this is bad db formating; the data is being pulled in from an external reporting system and is easier to keep in this format.*

    I want my manager table to take the ProductID and ManagerName from the details table, like so:

    ManagerID ManagerName ProductID GroupName
    1 Sally Smith 234 Paper
    5 Bob McBob 789 Pens

    I'm having big problems in trying to figure out how to join these (I would prefer to do it SQL). Does anyone know how to quickly do this? Any help is greatly appreciated!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    SELECT...
    FROM Details LEFT JOIN Managers ON Details.ManagerID = Managers.ManagerID

    LEFT could be INNER or RIGHT, as appropriate to the situation.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Lorlai is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    107
    Perfect! Thank you so much for the help. One more question: Is there a way to get the field to auto fill? Like if I had all the data in the details field, and wanted to get the matching fields in the Manager table filled with the appropriate data?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Typically you would not store anything other than the key (ManagerID) in the other table. I can't think of an automatic way to populate the table. You'd need to do it with an update query or something like this in a form:

    http://www.baldyweb.com/Autofill.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 2
    Last Post: 06-13-2011, 06:04 PM
  2. Replies: 14
    Last Post: 11-16-2010, 03:56 PM
  3. Syntax-reference to pages
    By AmyHill in forum Access
    Replies: 5
    Last Post: 08-27-2009, 10:04 AM
  4. Ms Access Reference Books
    By dbman in forum Access
    Replies: 2
    Last Post: 01-27-2008, 06:06 PM
  5. Access 2007 Attachments - Relative reference
    By soringc in forum Programming
    Replies: 0
    Last Post: 11-22-2007, 10:47 AM

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