Results 1 to 6 of 6
  1. #1
    joshearl is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2009
    Posts
    5

    Using subform to display and edit relationships

    I'm relatively new to Access but have some experience working with relational database structures. I'm completely stuck on what seems like a simple task.



    Here's the scenario:

    I have two tables, People and Relationships. The People table has a primary key, personID, as well as first and last name fields.

    The Relationships table has two foreign key fields, personID1 and personID2, as well as a relationshiptype field.

    As an example of what I want to accomplish, say we have a person who is a student, Lisa Smith. That person has a relationship with another person, Jerry Smith, who is her father. She also has a relationship with Michele Brian, who is her teacher.

    I'd like my subform to show the following:

    Jerry Smith Parent
    Michele Brian Instructor

    Instead, what I'm getting is:

    Lisa Smith Parent
    Lisa Smith Instructor

    I know exactly what's happening--the form is displaying the name based on the personID of the record that's currently open, rather than the personID2 of the relationships table (the relate-ee, if you will).

    This seems like something that I should be able to do using the form-building tools, rather than having to write a custom query.

    I am somewhat proficient in SQL, but I'm not sure how to write this one in the context of using it in a subform.

    Could someone point me in the right direction?

    Thanks,
    Josh

  2. #2
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows XP Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Need to see your Table design to be able to help.

  3. #3
    joshearl is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2009
    Posts
    5
    OK, what's the best way to do that?

  4. #4
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows XP Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Table Name

    Primary Key (Data Type)
    Foregin Key (Data Type)
    Other Fields (Data Type) etc

    Then

    Other Tables

    Explain Relationships etc

    Or Post a copy of your Database in 2003 but not 2007.

  5. #5
    joshearl is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2009
    Posts
    5
    Access won't let me save the database in 2003 format, so I'll just have to make do with screen shots.

    These are the two tables I'm trying to work with. The relationships.personID1 and relationships.personID2 fields are the foreign keys that relate back to the people.personID field in the person table.

    The personID1 field's value would be whatever record I currently have open. I'm trying to take the people.personID value of the open record, find all relationships where people.personID matches relationships.personID1, and then display the first and last names for all values in relationships.personID2.

    Does that make sense?

    Thanks for the help,
    Josh

  6. #6
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows XP Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    You only need ONE foregin key in the second table.

    Then show all records that the Primary key matches those in the second table.

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

Similar Threads

  1. Subform records wont display
    By taylorosso in forum Forms
    Replies: 10
    Last Post: 10-09-2009, 08:59 AM
  2. Can I make a subform display only?
    By nkenney in forum Forms
    Replies: 4
    Last Post: 04-01-2009, 11:50 AM
  3. Click a record to display it for edit
    By mapl in forum Access
    Replies: 0
    Last Post: 11-24-2008, 03:02 PM
  4. Can I edit a record with a subform?
    By bigmax in forum Forms
    Replies: 0
    Last Post: 08-11-2008, 07:55 AM
  5. Subform in a Subform and relationships
    By St3ph3n in forum Database Design
    Replies: 3
    Last Post: 12-06-2005, 06:34 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