Results 1 to 2 of 2
  1. #1
    mpreston14 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2013
    Posts
    41

    Query to pull multiples of same data from a table

    Hello everyone,



    I have a soccer/football referee database that I built that helps us score each referee by the level of match and league they work. We also have "observers" at some of these matches.

    In the master data table, each referee's assignment is given a MatchID that links the gamedate, gametime, gamenumber together with the data of the two or three referees that officiated as well as the observer if one was present. Each Ref/observer also has a unique ID. The data is imported via excel and the MatchID is an autonumber based on where the assignment is on the spreadsheet when imported.

    I would like to be able to list the GameNumbers that had both a referee and an observer.

    In my mind it seems so easy, but everything I have tried isn't working.

    Example of the data in the table:

    MatchID RefID League Match Position GameNumber GameDate GameTime
    1984 611 SL BU8 Referee 621 4/27/2013 2:15 PM
    258 32 SL BU8 Referee 621 4/27/2013 2:15 PM
    1141 791 SL BU8 Observer 621 4/27/2013 2:15 PM

    Any ideas as to how I can create a query to list:

    GameNumber GameDate GameTime RefID LastName Oberseved_By
    621 4/27/2013 2:15 PM 611 Jones LASTNAME (from ref table that links to # 791 in above example)

    I may add a field to the master data table that holds has an "Observed by" field and manually alter the import file to put it in the correct field at import, but for now I would like to get what I can out of the current set of data.



    Thanks,

    Mike

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,621
    What have you tried? Post the query you attempted.

    Criteria that depends on values in other records of same table is tricky. Often requiring subquery or domain aggregate function.

    Only one observer for each game?

    One way to try:

    SELECT GameNumber, GameDate, GameTime, RefID, DLookup("RefID", "tablename", "GameNumber=" & [GameNumber] & "Position='Observer'") AS ObsID FROM tablename;

    The resulting dataset will have the 3 records from your example but each will have the ObsID value, if the game had an observer.

    Now join that query to the Ref table to retrieve names. Join the Ref table twice, to RefID and ObsID fields.

    Can apply filter criteria to select only those records that are Referee position. That will eliminate the Observer record. Also apply criteria where there is a RefID and ObsID.
    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.

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

Similar Threads

  1. Pull Data from another table
    By bbranco in forum Access
    Replies: 1
    Last Post: 06-19-2013, 06:15 AM
  2. Replies: 3
    Last Post: 02-06-2013, 10:00 PM
  3. Replies: 1
    Last Post: 01-14-2013, 11:28 AM
  4. Replies: 3
    Last Post: 08-02-2012, 10:27 AM
  5. pull up data from a table into a form
    By MattD00 in forum Forms
    Replies: 1
    Last Post: 03-30-2011, 08:15 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