Results 1 to 10 of 10
  1. #1
    GTJamie is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    5

    Query to display selected records data based on fields in another table

    I am an access beginner so apologies if this is a stupid question (or has been answered many times before - my searching hasn't found a solution.



    I have a table called 'People' that contains individual's details and each record has a unique, numeric, 'People ID'. A second table called 'Events' contains details of the events and every record has a unique 'Event ID' and fields that contain details of attendees eg 'Attendee 1'. Attendee 2' etc. A new record is created for every new event and 'Attendee' fields are filled out through a form using a combo box that allows a user to select the participants name from 'People' and populates the 'Attendee' record with the 'People ID' for that participant. So an event would have a record showing, for example: Event ID = 39, Attendee 1 = 21, Attendee 2 = 36, Attendee 3 = 47 etc

    I want to run a query that shows all the individuals details (ie all fields from 'People') as a record for each attendee of the event.

    I set up a relationship between 'People ID' and 'Attendee 1', and applied the criteria filter based on 'Event ID'. This successfully brings through all the data for Attendee 1.

    I thought that by setting up another relationship between 'People ID' and 'Attendee 2' this would pull through records for both attendees. However, it doesn't and I just can't make it do what I want. Any help (set out in laymans terms please!) would be amazing - thanks in advance.



  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The attendee table should have 2 fields:
    EventID, AttendeeID

    then add all people for that event.

    The table is not: eventid,attendee1, attendee2,etc...

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi
    It sounds like you have your structure set up wrong.

    Are you saying that 1 Event can have many Attendees?


    Or are you saying that 1 Person can attend Numerous Events?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    You need a junction table that holds at least
    TableID ' PK for that table, call it what you will
    PeopleIDFK ' from the People table. Get rid of spaces in fieldnames, seriously.
    EventIDFK ' from the event table

    Then it becomes simple to get what you would need.
    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

  5. #5
    GTJamie is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    5
    Thanks - 1 event can have many attendees.

  6. #6
    GTJamie is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    5
    Thanks. It is currently set up as you suggest. However I am trying to change it to the alternative approach that I have outlined as it makes the data input much simpler and quicker.

  7. #7
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Welshgasman has given you the correct method for dong this.

    Man Form with a Subform
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  8. #8
    GTJamie is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    5
    Thanks for all the help. Can I ask the stupid question and ask what you mean by PK and FK?

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    PK Primary key for table
    FK Foreign Key in table which is the PK in another table and enables the link to exist between the two tables.
    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

  10. #10
    GTJamie is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    5
    Than you all for your help - you are amazing!

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

Similar Threads

  1. Replies: 1
    Last Post: 04-11-2022, 02:52 PM
  2. Replies: 4
    Last Post: 11-02-2015, 02:23 PM
  3. Display table data depending on selected data
    By swavemeisterg in forum Forms
    Replies: 7
    Last Post: 07-30-2013, 03:43 PM
  4. Replies: 14
    Last Post: 12-06-2012, 11:25 AM
  5. Replies: 6
    Last Post: 05-10-2012, 08:20 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