Results 1 to 2 of 2
  1. #1
    ArdNut is offline Novice
    Windows Vista Access 2010 64bit
    Join Date
    May 2013
    Posts
    1

    Question Creating blank records from new part of a composite key

    Hello

    I'm creating a database for a school. it contains the following tables: 'Students' of which the primary key is StudentID, 'Subjects' of which SubjectID is the key and 'Exams' - ExamID.

    Then, I have a table called 'Results' but with no primary key of its own - just 3 foreign keys from the other tables and another field which can be left blank let's call it 'Grade'. So the Results table would have the following fields:

    StudentID*, SubjectID*, ExamID*, Grade

    Now, I make a form which creates a new lets say ExamID and I would like to create records with all the combinations of all of the subjects and students, ready for the 'Grade' to be typed in. How would I go about doing that in the easiest way possible? This is assuming the Exam isn't based on the Subject directly.



    Thank you

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Will probably be complicated.

    Do a cartesian join of the 3 tables. Pull all 3 tables into query designer but don't set any links. Drag the ID fields to the grid. This should cause every record of each table to join with every record of the other tables, resulting in records of every possible combination. I have done this with 2 tables but never 3.

    Now the trick is to determine which of these records need to be copied into the Results table. Do a Find Unmatched query between the cartesian dataset and the Results table to isolate the cartesian combinations not already in the Results table.

    Then do INSERT SELECT sql action on the Find Unmatched query.
    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. How Can export Large table part by part
    By shabar in forum Import/Export Data
    Replies: 2
    Last Post: 02-04-2013, 06:29 AM
  2. Access 2007 - Creating New Records Based on Existing Records
    By GeorgeAugustinePhillips in forum Forms
    Replies: 9
    Last Post: 10-05-2011, 05:58 PM
  3. Blank Records in Table
    By anwaar in forum Access
    Replies: 3
    Last Post: 09-02-2011, 02:18 PM
  4. Sorting Blank Records
    By vicky464 in forum Reports
    Replies: 6
    Last Post: 12-29-2010, 10:41 AM
  5. Replies: 1
    Last Post: 07-27-2010, 08:02 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