Results 1 to 11 of 11
  1. #1
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146

    Text of foreign keys

    tblEvent contains foreign keys from multiple tables. The foreign key in tbleEvent is the autonumber from the "reference" table. I then run a query on tblEvent and get a result. How do I display on a report the underling text of the foreign key and not the autonumber of the foreign key?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,871
    How about posting a copy of your relationships window? It would be helpful to readers to see your table designs and relationships in context.
    It would also be helpful if you would post the SQL of your query.

  3. #3
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    Thanks for the reply. I can see I need to work on my relationships... to be continued

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,871

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,575
    Quote Originally Posted by mainerain View Post
    tblEvent contains foreign keys from multiple tables. The foreign key in tbleEvent is the autonumber from the "reference" table. I then run a query on tblEvent and get a result. How do I display on a report the underling text of the foreign key and not the autonumber of the foreign key?
    You join to the tables that have the foreign key as their primary key?
    That is the whole point of foreign keys?

    My links table does the same thing. It contains NOTHING except links to other tables and it's own primary key.
    Attached Thumbnails Attached Thumbnails links.PNG  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Whether or not you build relationships in Relationships window, report RecordSource would be a query that joins tables and binds textboxes to appropriate fields.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    In regards to your original question, one way is to use a query to include the desired fields, like this:

    Click image for larger version. 

Name:	qzample.png 
Views:	19 
Size:	26.6 KB 
ID:	48584

    You can even omit the foreign key fields if not needed by the query end result.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Dave, why does the link arrow for tblGenre appear backwards?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    Quote Originally Posted by June7 View Post
    Dave, why does the link arrow for tblGenre appear backwards?
    Appear? It is backwards! Good eye. I pulled the query out of an existing DB. I'll have to check out that DB and see what's going on. '¯\_(ツ)_/¯

    Edit: Checked it out. The example is correct for the situation. Genre is not present for all books, so the join type shown will pull all books regardless.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Okay. Had to explore that relationship so built tables and query. It's actually tblAuthors link that I would expect to see the other direction, in other words, both links the same type - RIGHT JOIN. However, seems to produce same output if tblAuthors link is LEFT JOIN.

    Why would a book not have genre? They all have author?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    Why would a book not have genre? They all have author?
    Genre was added a few months after go-live. A lot of work to add the Genre data to hundreds of books. Still not done.

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

Similar Threads

  1. Help with foreign keys
    By Irunit in forum Database Design
    Replies: 26
    Last Post: 08-22-2022, 11:19 AM
  2. Foreign Keys
    By RustyRick in forum Access
    Replies: 1
    Last Post: 04-19-2020, 03:56 PM
  3. Foreign keys
    By Accessuser67 in forum Access
    Replies: 1
    Last Post: 10-05-2015, 06:33 PM
  4. primary/foreign keys
    By st1300 in forum Database Design
    Replies: 38
    Last Post: 12-04-2011, 01:27 PM
  5. Need help with foreign keys
    By acdougla17 in forum Access
    Replies: 1
    Last Post: 09-26-2011, 03:50 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